Question

I have 2 branches in my Mercurial repository. 'default' and 'other'

default branch A - B - C - D

other branch E - F

I need to move B changeset to other branch. So it will look like this:

default branch A - C - D

other branch E - F - B

Is it possible?

Thanks in advance!

Was it helpful?

Solution

Graft-based solution

  • Graft (hg help graft) B to target branch
  • Remove (histed extension) B from source branch (graft only make copy of changeset, without removing original)

Rebase-based solution

  • Rebase B to other branch
  • Because rebase move also descendants of rebased changeset - rebase C back to default

OTHER TIPS

The following solution doesn't require enabling any extensions. It does assume the existence of the patch utility, though.

On default:

$ hg diff -c B > diff.out
$ hg backout --merge -r B
$ hg merge
$ hg ci

On other branch:

$ patch -p1 < diff.out
$ hg ci
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top