Changing what branch a merge is on without redoing the merge?

If somebody has merged branch B into branch A, but meant to merge A into B (so that the commit would be on branch B), is there a method I could use to get that merge (and all of it's descendents) into branch B? Besides redoing the merge, which was a considerable amount of work.

Upvotes: 1

Views: 50

Answers (2)

dwardu
dwardu

Reputation: 2300

Assuming that you’ve just committed the merge, or if not, that the merge changeset 1. has no children and 2. is the parent of your working directory, then:

hg branch B --force
hg commit --amend

Upvotes: 0

Mathiasdm
Mathiasdm

Reputation: 1831

The following approach should solve your issue, but is not really 'clean'.

  1. Update to branch B (just before the merge).
  2. Start a new merge with branch A. To avoid any interactivity, you can use 'hg merge --tool internal:local'. The actual merging doesn't matter, as you'll use the results from your previous merge.
  3. Revert to the previous merge: hg revert --all -r OLD_MERGE_CHANGESET
  4. Commit the merge.
  5. Use 'hg rebase' to move all your later commits on top of the correct branch.

Upvotes: 1

Related Questions