Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mercurial: how to cherry pick during merging

Consider I have the following situation:

I have a branch br_foo from revision 4. After that there are 3 more changes made on default branch: 6, 7 and 8. I'd like to only merge changes 7 and 8 to br_foo. Is there a way to achieve this in mercurial?

like image 757
lang2 Avatar asked Dec 02 '11 12:12

lang2


People also ask

How do you cherry pick a merged pull request?

You can use the GitLab UI to cherry-pick merge requests into a project, even if the merge request is from a fork: In the merge request's secondary menu, click Commits to display the commit details page. Click on the Options dropdown and select Cherry-pick to show the cherry-pick modal.

Is a merge but no option cherry pick?

Usually you cannot cherry-pick a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows cherry-pick to replay the change relative to the specified parent.

How do I merge Mercurials?

To merge two branches, you pull their heads into the same repository, update to one of them and merge the other, and then commit the result once you're happy with the merge. The resulting changeset has two parents.


1 Answers

Graft v Transplant

Depending on which version of Mercurial you are using, you will probably use either the new Graft functionality in Mercurial 2.x or the older Transplant Extension for earlier versions of Mercurial.


The Graft command

This was announced recently (Nov 2011) so I haven't had a chance to work with it myself.

This command uses Mercurial's merge logic to copy individual changes from other branches without merging branches in the history graph. This is sometimes known as 'backporting' or 'cherry-picking'. By default, graft will copy user, date, and description from the source changesets.


The Transplant Extension

I've used it for just this scenario. A little snippet from the description ...

This extension allows you to transplant patches from another branch or repository.

It records the original changeset ID in the transplanted changeset, and avoids transplanting previously-transplanted patches.

It can also be used to rebase a branch against upstream changes (including dropping changesets that have been adopted upstream), to rewrite changesets and to cherrypick some changesets.

like image 74
Chris McCauley Avatar answered Sep 19 '22 02:09

Chris McCauley