我们正在尝试克隆一个Mercurial存储库A,它引用了一个移动主机的子存储库B. 我们想在A中更新.hgsub指向B的新位置,但如果我们不能首先克隆A,那就是鸡和蛋的问题.
有谁知道如何解决这个问题?
$ 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.
...
Run Code Online (Sandbox Code Playgroud)
因此,您可以.hgrc在一个[subpaths]小节中做到这一点。
首先请注意,clone是init + pull + update,而subrepo cloning是更新步骤的一部分,而不是 pull步骤.这意味着您可以通过跳过更新步骤来避免克隆失败:
$ hg clone -U <url>
Run Code Online (Sandbox Code Playgroud)
现在问题被简化为"如何使用有问题的.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
Run Code Online (Sandbox Code Playgroud)
现在,您可以手动修复子项和.hgsub并提交.在推送之前,请务必使用克隆测试您的修复程序.
另外,请参阅以下主题的邮件列表主题:http://markmail.org/thread/ktxd2rsm7avkexzr