4

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!

GaryO
  • 5,873
  • 1
  • 36
  • 61

2 Answers2

1

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.

Community
  • 1
  • 1
Paul S
  • 7,645
  • 2
  • 24
  • 36
  • If you want to publish your changes, Mercurial will complain about multiple heads on a branch. You need to call `hg push --force`. (But I agree that just closing the wrong head and continuing from an earlier revision is the cleanest solution. Merging the head will once again lead to trouble if you eventually want to merge the branch again.) Note: BitBucket now supports stripping revisions using the administration GUI of the remote repository. – Mike Rosoft May 24 '18 at 13:33
0

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.

Oben Sonne
  • 9,893
  • 2
  • 40
  • 61