Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial/TortoiseHG Merge Trunk Changes into Branch

I just switched over from SVN where after a few changes to the trunk I would merge a range of revisions (from my last merge from the trunk to the branhc - HEAD) into a branch. I want to do the same with Mercurial using TortoiseHG but I can't figure out how. I just committed two changesets to the trunk, now I need the branch to integrate those changes. Thanks in advance!

like image 418
Hungry Beast Avatar asked Sep 30 '10 16:09

Hungry Beast


2 Answers

I've written a guide about working with branches in Mercurial. It boils down to this:

$ hg update mybranch # unless you are already at the tip of the branch
$ hg merge default   # merge in latest changes from "trunk"
$ hg commit -m 'Merge with default'

When mybranch is done, you close it and merge it into default:

$ hg commit --close-branch -m 'Ready for merge'
$ hg update default
$ hg merge mybranch
$ hg commit -m 'Integrated mybranch'

The cool thing about Mercurial is that you use the same commands no matter which direction you are merging. Subversion's merge tracking system requires you to add special command line flags when you merge in one direction, but not in the other (I cannot remember which direction is which without looking it up in the manual).

like image 79
Martin Geisler Avatar answered Nov 10 '22 09:11

Martin Geisler


In hg (or any DVCS) you can merge any changeset with any other changeset (except ancestors). If you open repository log from TortoiseHG (View Changelog from Explorer context menu or hgtk log from command line), you can update to any changeset, then select "merge with".

In your specific case you would update to your branch head, then merge with trunk head.

like image 26
Geoffrey Zheng Avatar answered Nov 10 '22 08:11

Geoffrey Zheng