开发者

Creating a local transparent cache of a mercurial repository

I have lots of different clones which I work on separately. When I want to update those clones, it can be quite slow to update them from the server. So instead I have a "clean" clone, which I update from the server regularly, and all the other clones clone from the clean clone (hope that makes sense).

But now what I have is a two-step approach. First go to the clean clone and pull, and then go to the real clone i'm working on and pull from the clean clone. Can this be made into 1 step?

Ideally, the "clean" clone would be transparent: when it's pulled from, it would do a pull itself. That way 开发者_C百科we'd have caching and 1-step. Is there a way to do this?


Keeping a clean clone locally is very common and a good idea in general. I've always stuck with the two step process you describe, but you could do this with hooks if you wanted.

In your cache repos you'd put soemthing like this in the .hg/hgrc file:

[hooks]
preoutgoing = hg pull

which tells that repo to do a hg pull before it bundles up changes in response to a pull or clone request made on it.

Note that even if the downstream (real clone) repo requests a subset of the changesets using pull -r or clone -r this cache repo will pull down everything. That's likely what you want since your goal is a mirror but the commenter points it's worth pointing out.


You can do this using hooks. In your <clean-clone>/.hg/hgrc, add these as a first draft:

[hooks]

# Before a pull from this repository, pull from upstream.
preoutgoing.autopull = [ $HG_SOURCE = 'pull' ] && hg pull

# After a push to this repository, push to upstream.
changegroup.autopush = [ $HG_SOURCE = 'push' ] && hg push

(Note: "autopush" and "autopull" are optional identifiers with no special meaning; you can leave them out if you have no other hooks defined.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜