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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With