Ignacio Martínez
Ignacio Martínez

Reputation: 702

How can I fix this bad Merge in Mercurial?

Gprah capture

I have this scenario. First of nothing, yes I know, we are working directly on the trunk, that will change tomorrow (literally).

This guy merged code and walked over everybody else code. I'd like to bring up the 1625 REV. Is there a way? I don't care losing what comes next, he deserves to do his work again.

I was thinking doing a branch from 1625. But what would happen if I want to merge with default later? Can I just stay with everything that would be in the new branch?

Upvotes: 0

Views: 675

Answers (2)

Kirill
Kirill

Reputation: 3454

Try this recipe:

  1. Clone your repo to repo-clone.
  2. Update repo-clone to good revision.
  3. Update repo to tip revision.
  4. Remove all except .hg from repo.
  5. Copy all except .hg from repo-clone to repo.
  6. Commit in repo with hg ci -A -m 'Backout bad merges'.

The last command will add all untracked files and forget all missing files before commit. With this recipe you'll get exactly the same state of working directory as in the good revision.

Upvotes: 1

Ringding
Ringding

Reputation: 2856

Basically like this: check out the good version, merge the other head, revert to the good version, commit.

hg up -C <good>
hg merge <bad>
hg revert -r <good> --all
hg resolve -m #if necessary
hg ci -m kill-merge
hg diff -r <good> #should be empty

Upvotes: 3

Related Questions