Merging Mercurial branches from separate repositories
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
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
.
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
![Paul](https://i.stack.imgur.com/VCYAB.jpg?s=256&g=1)
Paul
Updated on March 25, 2020Comments
-
Paul over 4 years
I'm trying to figure out how to merge branches from a separate repo into the current.
I have the following:
PJT1 - contains branches default and foodog
PJT2 - contains branch default
from PJT2, I do the following:
$ hg fetch -y ../PJT1 -r foodog -m "this is a test"
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)
and
hg branch
reveals the following:[someone@myhome pjt2]$ hg branch foodog
How do I get the contents from PJT1's
foodog
branch into PJT2'sdefault
branch?