如何使用Mercurial将功能分支与具有子存储库的默认值合并

我有许多子库存项目:

/project              <- Main repository
/project/src          <- Source code subrepository  (subrepository to /project)
/project/src/module   <- Module subrepository (subrepository to /project/src repository)

我现在已经开发了一个功能分支(feature1),它有一些修改,我现在想要合并回默认分支.自创建feature1分支以来,默认分支没有任何更改.

我已经尝试将分支合并到默认值,但最终会在子库中发生一些奇怪的事情.

我已按照此other post中的说明操作,并获得以下结果:

$hg checkout default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$hg merge feature1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
$hg status -S
  M .hgsubstate
$hg commit -S -m "branch merge test"
  nothing changed
$hg branches
   default                       19:c2398dc23428
   feature1                      17:98dc0efbad90 (inactive)

奇怪的是,即使在模块子存储库中更改了许多文件,合并也只表示已更新1个文件.我假设这恰好是.hgsubstate.

当我显式更新子库时,我得到以下内容:

$cd src/module
$hg update
  39 files updated, 0 files merged, 23 files removed, 0 files unresolved
$cd ../..
$hg commit -S -m "feature1 merge"
   committing subrepository src
$hg status -S
   M .hgsubstate

因此,在进行hg更新以将所有更改带入工作目录之后,我看到了我需要提交的模块子存储库中的更改.但是,.hgsubstate始终保持修改状态.我试过hg删除.我试过忘了忘记.但无论我做什么,当我做一个hg状态时它仍然被标记.

所以我的问题是:

>我采取的流程是否正确合并分支(考虑子仓库存在)?
>是否有必要在子存储库中执行hg更新以使主存储库识别更改?
>为什么.hgsubstate行为不端?

最佳答案 你没有说你正在使用哪个版本的hg – subrepo支持随着时间的推移已经改变了一定的数量.我刚试过像hg v2.8中3个subrepo级别的测试,它对我有用.

如果你在顶级获得一个脏的.hgsubstate,那么当你提交一个subrepo时这是正常的. [如果只有一个subrepo被独立提交,那么只有.hgsubstate会在顶层变脏.]如果你然后上升到顶级并在该级别提交,则会提交.hgsubstate,一切都很好.请记住,顶级repo以与文件类似的方式跟踪subrepos – 它在每个顶级提交中从subrepo提交特定的变更集.

FWIW.建议的做法是单独提交subrepos,即如果subrepos是脏的,则避免在顶层提交.原因是subrepos通常需要一个不同的提交消息 – 毕竟它们是subrepos的原因;但如果你愿意,你可以在顶层提交.在你的情况下有3个级别,顺序是:

cd src/module
hg commit -m "src/module commit reason"
cd ..
hg commit -m "src commit reason"
cd ..
hg commit -m "top level reason"

意图是subrepos不经常改变,例如,第三方图书馆.如果您的子计划经常发生变化,您和您的团队必须保持警惕以避免错误,特别是在与其他人合作时. [但考虑到问题的日期,你现在可能已经解决了这个问题.]

点赞