Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge only one changeset from another branch

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:

  1. I start with an stable revision R1
  2. I continue developing on R1: CS1,CS2,CS3
  3. At some point I need to solve bug from my stable revision R1. And I want to apply only one changeset from developing line (fe CS2)

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,

like image 778
lujop Avatar asked Aug 18 '11 20:08

lujop


People also ask

How do I merge changesets in another branch?

Use the drag and drop operation to merge branches You can use the drag and drop feature to merge a changeset or a branch to another branch. For more information, see Merge folders and files.


1 Answers

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

like image 145
Larzan Avatar answered Nov 02 '22 21:11

Larzan