简体   繁体   中英

Local cache of mercurial repository: how to get “hg incoming” to pull, which hook?

I use a local repository cache so my clones are faster. When I clone I clone from the local cache, which auto-updates before the clone actually starts. When I push, I push to the local cache which first updates and then (when the push is successfull) pushes the changesets onwards to the canonical repository.

However: I want "hg incoming" to work as follows:

  1. I make a clone of the local cache repository
  2. ..hack hack hack in the clone of the local cache..(hey are there any incoming changes? I wonder)
  3. $ hg in
  4. The local cache repository gets asked "are there any new changesets?"
  5. The local cache then first does hg pull
  6. Then it answers the question

Is this possible? Is there a hook I can use in the local cache repository that fires when it gets a "hg incoming" command?

The .hgrc in my local cache looks like:

[hooks]
# We want to make sure this repository has the latest changesets just before
# we do a clone of it.
preoutgoing.update_local_cache1 = echo "======================"
preoutgoing.update_local_cache2 = echo "hg pull from canonical"
preoutgoing.update_local_cache3 = echo "======================"
preoutgoing.update_local_cache4 = hg pull

# Before we push commits to the local cache make sure it's up to date.
prechangegroup.update_local_cache1 = echo "======================"
prechangegroup.update_local_cache2 = echo "hg pull from canonical"
prechangegroup.update_local_cache3 = echo "======================"
prechangegroup.update_local_cache4 = hg pull

# Just after a bunch of changesets have been succesfully pushed to this local
# cache repository, push it further to the canonical repository.
changegroup.push_to_canonical1 = echo "===================="
changegroup.push_to_canonical2 = echo "hg push to canonical"
changegroup.push_to_canonical3 = echo "===================="
changegroup.push_to_canonical4 = hg push

There's no hook you can use in the local cache to catch when one of your working clones is checking for incoming available stuff. Your best best is probably to get the working clones to do the pull in the local cache. Something like in your user-wide ~/.hgrc file should do it

[hooks]
pre-incoming = $HG --repository /path/to/local/cache pull

THen whenever you do hg incoming in any repository you'll do a pull in the local cache first. That, of course, won't work well when you're running hg incoming in the actual local cache, turning it into a pull instead, but no tragedy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM