我們試圖克隆一個Mercurial倉庫A,它引用一個移動主機的子倉庫B.我們希望更新A中的.hgsub指向B的新位置,但如果我們不能克隆克隆A,那麼這是一個雞和雞蛋問題。克隆一個mercurial倉庫,.hgsub是指一個死的外部subrepo
有誰知道如何解決這個問題?
我們試圖克隆一個Mercurial倉庫A,它引用一個移動主機的子倉庫B.我們希望更新A中的.hgsub指向B的新位置,但如果我們不能克隆克隆A,那麼這是一個雞和雞蛋問題。克隆一個mercurial倉庫,.hgsub是指一個死的外部subrepo
有誰知道如何解決這個問題?
首先注意克隆是init + pull + update,並且該子文件克隆是更新步驟的一部分,而不是的拉動步驟。這意味着你能避免簡單地克隆失敗,跳過更新步驟:「我怎麼更新到了問題的.hgsub/.hgsubstate文件修訂」
$ hg clone -U <url>
現在的問題歸結爲這裏有兩種可能性:使用[子路徑]功能
重映射subrepos(見汞柱幫助subrepo和Hg幫助配置)
手動更新和修復
A「手冊更新「可以這樣做:
$ hg revert -a -r default -X problematic-file
[adding a bunch of files]
$ hg debugrebuildstate -r default
現在你可以手動修復你的subrepos和.hgsub並提交。在推送之前,務必使用克隆測試您的修復程序。
而且,看到這個郵件列表線程的話題:http://markmail.org/thread/ktxd2rsm7avkexzr
$ 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.
...
所以,你可以在[subpaths]
部分做在.hgrc
。
我不知道如何可以做到這一點,所以答案顯示正是我找到了。 'hg help'和'man'是很棒的工具。 –