合并来自不同存储库的Mercurial分支 [英] Merging Mercurial branches from separate repositories
问题描述
我试图弄清楚如何将分支从一个单独的仓库中合并到当前仓库中.
I'm trying to figure out how to merge branches from a separate repo into the current.
我有以下内容:
PJT1 -包含默认的分支和foodog
PJT1 - contains branches default and foodog
PJT2 -包含分支默认值
PJT2 - contains branch default
在PJT2中,我执行以下操作:
from PJT2, I do the following:
$ hg fetch -y ../PJT1 -r foodog -m "this is a test"
现在,如果我查看PJT2,我会看到正确的文件和更改.但是,如果执行hg branches
,我将得到以下信息:
Now, if I look in PJT2, I see the correct files and changes. However, I if I do hg branches
, I get the following:
[someone@myhome pjt2]$ hg branches
foodog 1:c1e14fde816b
default 0:7b1adb938f71 (inactive)
和hg branch
显示以下内容:
[someone@myhome pjt2]$ hg branch
foodog
如何从PJT1的foodog
分支获取内容到PJT2的default
分支?
How do I get the contents from PJT1's foodog
branch into PJT2's default
branch?
推荐答案
您需要合并,但是请记住,foodog分支上的更改将始终位于foodog上-分支永远不会消失,但可以将其隐藏.此命令序列与您所要询问的尽可能接近:
You need to merge, but keep in mind changes on branch foodog will always be on foodog -- branches never go away but they can be hidden. This sequence of commands is as close as you'll get to what you're asking:
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
之后,除非您执行hg branches --closed
,否则您将看不到foodog
.
After the merge hg branches
will still show foodog
unless you do hg branches --active
which only shows branches that have heads on them. After the commit --close-branch
you won't see foodog
unless you do hg branches --closed
.
这是因为Mercurial中的分支永远不会完全消失(一项设计功能),因此它们通常仅保留给诸如release-1.0
或stable
之类的终身使用.对于漏洞和功能之类的短暂工作,请考虑使用书签.这是两者的绝佳对比: http://stevelosh .com/blog/2009/08/a-guide-to-branching-in-Mercurial
It's because branches in Mercurial never go away entirely (a design feature) that they're often reserved only for life-long things like release-1.0
or stable
. For short-lived efforts like bugs and features consider using bookmarks instead. Here's a great comparison of the two: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial
这篇关于合并来自不同存储库的Mercurial分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!