johannestaas
johannestaas

Reputation: 1225

Can I create a branch in mercurial that undoes previous merges?

I would like to go back to a working revision, and pull EVERY changeset I've made since that revision, into a new branch. Basically, I have merged from the main branch a few times, and would like to reverse those out.

Is this possible? Are there any tools that could help me do this?

Upvotes: 0

Views: 44

Answers (1)

Ry4an Brase
Ry4an Brase

Reputation: 78350

If your history looks like this:

[M1]--[M2]----[M3]---[M4]----[M5]----[M6]
   \            \               \
    [B1]--[B2]--[B3]----[B4]----[B5]----[B6]

Where M# is a changeset on the default branch, and B# is a changeset on an existing branch and B3 and B5 are merge changesets, and your goal is to get something like this:

[M1]--[M2]----[M3]---[M4]----[M5]----[M6]
   \
    [B1]--[B2]--[B4]----[B6]

THen you can get that by doing:

hg update M1
hg branch new_branch_I_want
hg graft B1 B2 B4 B6

That will pull those changes into your new branch. Of course the old branch will still exist in its unmodified state. Since graft skips merge changesets you could probably specify the entire B1::B6 range, but I've not tried it.

Upvotes: 2

Related Questions