mercurial存储库的本地缓存:如何获取“hg incoming”来拉,哪个挂钩?

时间:2014-09-14 20:27:36

标签: version-control mercurial

我使用本地存储库缓存,因此我的克隆速度更快。 当我从本地缓存克隆我克隆时,在克隆实际启动之前自动更新。当我推送时,我会推送到首先更新的本地缓存,然后(当推送成功时)将更改集推送到规范存储库。

但是:我希望“hg incoming”按以下方式工作:

  1. 我复制了本地缓存存储库
  2. .. hack hack hack in clone of local cache ..(嘿,有什么传入的变化吗?我不知道)
  3. $ hg in
  4. 本地缓存存储库被问到“是否有任何新的变更集?”
  5. 然后本地缓存首先执行hg pull
  6. 然后它回答了问题
  7. 这可能吗?是否有可以在本地缓存存储库中使用的钩子,当它获得“hg incoming”命令时会触发?

    我本地缓存中的.hgrc如下所示:

    [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
    

1 个答案:

答案 0 :(得分:2)

当你的一个工作克隆正在检查传入的可用内容时,你可以在本地缓存中使用钩子来捕获。你最好的可能是让工作克隆在本地缓存中拉动。您的用户范围~/.hgrc文件中应该执行此操作

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

无论何时在任何存储库中执行hg incoming,您都将首先拉入本地缓存。当然,当您在实际的本地缓存中运行hg incoming时,这将无法正常工作,而是将其变为拉动而不是悲剧。

相关问题