Reputation: 13873
I'm new to mercurial and I read that it's not possible to merge only a separate changeset from another branch. Then I don't know what's the best approach to solve that:
What's the best aproach? As merging didn't work what I've done is make a patch of CS2 and then apply the patch in the new stable branch to fix the bug. That's the Mercurial way?
Cheers,
Upvotes: 13
Views: 10999
Reputation: 9667
UPDATE: No need for any extension anymore as of Hg 2.0
As 'CAD bloke' pointed out, this is exactly what the graft command is for which was introduced in Hg 2.0.
SourceTree
The easiest way to do this is with a GUI like SourceTree, just double-click on the TARGET branch to switch, then press the right mouse button on any other revision and select the 'Graft' command (strangely it can also be a revision of the current branch). If there are no conflicts SourceTree will immediately create a new revision for the current branch.
TortoiseHg
Exactly the same, select TARGET Branch, then rmb over the revision you want to graft: How to graft with TortoiseHg
Command Line
To do this with the command line just switch to the TARGET branch and then execute
hg graft -r {revision_number}
with {revision_number} obviously being the number of the revision you want to incorporate into you current branch. This will create a new changeset in you current branch with all the files from the revision whose number you used in the command.
To find out more about the graft command read this thread here on stackoverflow
Upvotes: 13
Reputation: 20881
The transplant extension automates what you've done to a single command.
But I think the preferred way (which depending on the scenario isn't always possible) is to make the fix on top of R1
in the first place, and then merge that to your development tip.
That is:
R1
.cs1...csN
.R1
, so you hg update R1
.R2
.hg update csN
.hg merge R2
, hg commit
...csN+1
.Upvotes: 8