GaryO
GaryO

Reputation: 6348

How can I back out a backout of a merge in mercurial?

I looked around on SO but didn't see my exact case here, so I hope someone can help.

The SCons project (https://bitbucket.org/scons/scons) does development on the default branch. I recently erroneously merged in AND PUSHED some changes from a developer's (call him DEV) repository which were not ready to be merged. So I had to back out those changes (hg backout -rXXX --parent YYY) and push that to bitbucket. But how can we move forward now? The backout wiki page says:

Warning: Backing out a merge will lead to trouble if you ever want to redo the merge. The only safe way to deal with a bad merge is to abandon the branch.

Of course we can't abandon the default branch. So now DEV can't merge from the main repo, or he'll lose all his changes in progress (because my backout deletes them). Nobody can now merge from DEV's repo, because the bitbucket repo already has all his changes (and the backout). We seem to be in a tough spot.

I guess I have two questions:

  1. What should we do now, to get DEV able to make progress: he needs a repo with his changes where he can work, in such a form that when he's done those changes can be merged into the bitbucket repo.

  2. What should I have done once I discovered the pushed merge was wrong?

(Note that there are no named branches here; everything is on default.)

Thanks!

Upvotes: 4

Views: 702

Answers (2)

Paul S
Paul S

Reputation: 7755

Of course we can't abandon the default branch.

Sure you can. Update to before the merge and continue work there, that's now the tip. If there are changes on the old branch that you need graft them over. You can then do a no-op merge to tie off the dead head, or you can just close it with hg commit --close-branch. Take a look at this answer.

Upvotes: 1

Oben Sonne
Oben Sonne

Reputation: 9953

No time to test this, but I guess it should work like this:

  1. DEV pulls from the main repo,
  2. makes a backout of the backout, and then
  3. continues to work on his feature locally.

From this state on, others should also have no trouble in merging in new changes from DEV.

Upvotes: 0

Related Questions