克隆一个mercurial存储库,.hgsub指的是一个死的外部子库

时间:2011-09-30 23:09:31

标签: mercurial

我们正在尝试克隆Mercurial存储库A,它引用了一个移动主机的子存储库B.我们想在A中更新.hgsub以指向B的新位置,但如果我们不能首先克隆A,那就是鸡和蛋的问题。

有谁知道如何解决这个问题?

2 个答案:

答案 0 :(得分:5)

首先请注意,clone是init + pull + update,而subrepo cloning是更新步骤的一部分,不是拉取步骤。这意味着只需跳过更新步骤即可避免克隆失败:

$ hg clone -U <url>

现在问题被简化为“如何使用有问题的.hgsub / .hgsubstate文件更新到修订版?”这里有两种可能性:

  • 使用[subpaths]功能重新映射子设备(请参阅hg help subrepo和hg help config)

  • 手动更新和修复

“手动更新”可以这样做:

$ hg revert -a -r default -X problematic-file
[adding a bunch of files]
$ hg debugrebuildstate -r default

现在,您可以手动修复子项和.hgsub并提交。在推送之前,请务必使用克隆测试您的修复程序。

另外,请参阅以下主题的邮件列表主题:http://markmail.org/thread/ktxd2rsm7avkexzr

答案 1 :(得分:4)

$ hg help subrepos
...

    Remapping Subrepositories Sources
    ---------------------------------

    A subrepository source location may change during a project life,
    invalidating references stored in the parent repository history. To fix
    this, rewriting rules can be defined in parent repository "hgrc" file or
    in Mercurial configuration. See the "[subpaths]" section in hgrc(5) for
    more details.

$ man hgrc
...

   subpaths
       Defines subrepositories source locations rewriting rules of the form:

       <pattern> = <replacement>

       Where  pattern  is  a regular expression matching the source and replacement is the replacement string used to
       rewrite it. Groups can be matched in pattern and referenced in replacements. For instance:

       http://server/(.*)-hg/ = http://hg.server/\1/

       rewrites http://server/foo-hg/ into http://hg.server/foo/.

       All patterns are applied in definition order.

...

因此,您可以在.hgrc部分[subpaths]中进行此操作。