我正在试图找出如何将分支从单独的仓库合并到当前仓库中。
我有以下内容:
PJT1 - 包含分支默认和foodog
PJT2 - 包含分支默认值
来自PJT2,我做了以下几点:
$ hg fetch -y ../PJT1 -r foodog -m "this is a test"
现在,如果我查看PJT2,我会看到正确的文件和更改。但是,如果我hg branches
,我会得到以下内容:
[someone@myhome pjt2]$ hg branches
foodog 1:c1e14fde816b
default 0:7b1adb938f71 (inactive)
和hg branch
显示以下内容:
[someone@myhome pjt2]$ hg branch
foodog
如何从PJT1的foodog
分支机构获取内容到PJT2的default
分支?
答案 0 :(得分:55)
你需要合并,但要记住分支foodog上的变化总是在foodog上 - 分支永远不会消失,但它们可以隐藏起来。这一系列命令就像你要问的那样接近:
cd PJT2
hg update default # just in case you were somewhere else
hg pull ../PJT1 -r foodog # that gets you foodog
hg merge foodog # that merges the changes into default
hg commit # commit the merge
hg update foodog # go to the most recent change in foodog (note: it is not a 'head')
hg commit --close-branch
合并后hg branches
仍会显示foodog
,除非你hg branches --active
只显示有头的分支。在commit --close-branch
之后,除非您执行foodog
,否则您将看不到hg branches --closed
。
这是因为Mercurial中的分支永远不会完全消失(设计特征),它们通常只保留给release-1.0
或stable
这样的终身事物。对于像bug和功能这样的短期工作,请考虑使用书签。以下是两者的完美比较:http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial
答案 1 :(得分:0)
您也可以尝试使用rebase扩展程序。它看起来像这样:
hg fetch -y ../PJT1 -r foodog -m "this is a test"
hg rebase --source <sRev> --dest <dRev>
rebase操作将分离changeset sRev 和所有后代,并将更改组应用于changeset dRev 。默认情况下,更改将应用于默认分支。因此,在您的情况下, sRev 将是分支 foodog 上的第一个变更集, dRev 将是默认变更集你想把它们应用到。
最后,如果要覆盖它并保留源分支名称,可以使用rebase选项--keepbranches
。您的问题表明这正是您不想做的事情,但仍应注意。