I posted a close-request-link to a likely duplicate (Mercurial: make one branch identical to another) but I thought I would add the following...
Grafting is definitely not what you want here. Grafting means copying a changeset, or some number of changesets, from one branch or thread-within-a-branch1 to another.
It is possible to use hg merge
to copy a different branch's tip commit (or any non-tip commit, really) to your own branch using the :other
built in merge-tool.2 This records an actual merge, unlike the other answer's close-and-reopen method. There's no particular reason to favor one method over the other.
1It's not clear what to call these. Edit: Mercurial documentation calls these anonymous branches. You get them when you use Mercurial in a more Git-like fashion, using bookmarks to keep track of multiple heads within a single named branch:
c4--c5 <-- bookmark1
/
default: c1--c2--c3 <-- bookmark2
\
c6--c7--c8 <-- bookmark3
In Git, these bookmarks are the branches: there are no permanent branches at all, and all you get are bookmarks.
(Side note: it's not clear if Mercurial considers c3
an anonymous branch. Commit c3
is not a head, and will not be listed by hg heads
, even though it has a bookmark identifying it. The anonymous branch effectively sprouts later, if and when you update to the bookmark and then create a new commit, dragging the bookmark along to track its progress.)
2This is the equivalent of Git's missing -s theirs
merge strategy. Compare with :local
, which is the equivalent of Git's -s ours
strategy, and contrast tis with :merge-local
or :merge-other
, which merge changes from both sides, but favor our or their side for automatic merge conflict resolution.