The release announcement for Mercurial 2.0 mentions a new graft command, which on first sight looks similar to the transplant extension. What is the difference between these two? Does cherry picking with graft solve any problems that existed with transplant, and if so, what are these?
Asked
Active
Viewed 1.9k times
2 Answers
72
Graft uses Mercurial internal merging, while transplant relies on patch mechanism. Therefore graft should be able to handle three-way-merges better than transplant currently does.

Neeme Praks
- 8,956
- 5
- 47
- 47

gizmo
- 11,819
- 6
- 44
- 61
-
18Graft is basically `transplant` redone as a core feature. The transplant extension should not be needed anymore. – Laurens Holst Nov 04 '11 at 15:34
-
1Except graft seems to not support an interactive mode like transplant did? Not tested, just from reading docs. – Jürgen A. Erhard Nov 23 '11 at 21:53
-
18@LaurensHolst: `graft` doesn't seem to be able to copy a change from a completely separate repository, whereas `transplant` _can_, using a command-line switch. – voithos Mar 10 '12 at 00:01
-
3Note that you can merge to a repository, graft, and then [prune the undesired branch](http://mercurial.selenic.com/wiki/PruningDeadBranches) to effectively graft between repositories. I just did this and I got what I wanted. – David Oct 24 '12 at 20:11
-
@David: but if you're doing all that, why not just manually apply the patch instead? It's not like you're getting any advantages merging since you can't merge external things anyhow. – Eamon Nerbonne Dec 19 '12 at 15:06
-
@EamonNerbonne: Graft preserves some properties of the original changeset (date, long hash) and at least with TortoiseHg allows me to graft multiple changesets with a single command. – David Jan 14 '13 at 18:32
-
@David: fair enough. I'm pretty sure you can import multiple patches simultaneously otherwise too. However, graft cannot preserve the hash (no method can) since that also depends on the parent, which has changed. I guess there's a common theme in hg (and git), which is that there are lots of ways to do something, and it's not very important which you pick. Graft is just yet another tool to play with your patches. – Eamon Nerbonne Jan 14 '13 at 23:44
-
@EamonNerbonne: Sorry, I'll clarify: it preserves the original hash in an extra field which TortoiseHg also conveniently displays. I think Mercurial internally uses this field to prevent re-grafting the same changeset in the future. – David Jan 15 '13 at 19:40
-
Oh yeah, that's quite handy :-) – Eamon Nerbonne Jan 17 '13 at 08:40
14
From the documentation of hg graft it looks like opposite to the transplant extension graft only handles branches within the same repository but can't handle different repositories.

Peter
- 785
- 2
- 7
- 18