merged two branches, and pushed, how to backout/strip?

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Jan 9 10:54:38 UTC 2017



On 01/08/2017 10:55 PM, Arne Babenhauserheide wrote:
> Uwe Brauer <oub at mat.ucm.es> writes:
>> I merged a feature branch into default and pushed. I shouldn't have
>> done. If that were a private repo, I would strip and that it is, but now
>> how I am supposed to clean up the mess, the graph looks basically like
>> this:
>>
>> @    changeset:   143:ec02f4c5e97e
>> |\   tag:         tip
>> | |  parent:      138:7e1a64287b87
>> | |  parent:      142:1dd731cf6a6a
>> | |  user:        Uwe Brauer <oub at mat.ucm.es>
>> | |  date:        Sun Jan 08 19:42:20 2017 +0000
>> | |  summary:     Merged
>> | |
>> | o  changeset:   142:1dd731cf6a6a
>> | |  branch:      vs-11.89
>> | |  user:        Uwe Brauer <oub at mat.ucm.es>
>> | |  date:        Sun Jan 08 09:57:53 2017 +0000
>> | |  summary:     Update Makefile and style/*.el
>>
>> 143:ec02f4c5e97e is the unwanted merge. I tried to rebase, but this was
>> of course refused.
>>
>> I might update to the last commit in the default branch, add stuff
>> commit and push creating a new head, but are there better solutions?
>
> If the code being in the open is no problem, you can always revert
> default to the commit before the merge, then commit, then merge default
> into vs-11.89, revert vs-11.89 to the other commit before the merge and
> commit again.
>
> hg revert --all -r 138:7e1a64287b87
> hg commit -m "backout bad merge"
> hg up vs-11.89
> hg merge default
> hg ci -m "merge default with the backout"
> hg revert --all -r 142:1dd731cf6a6a
> hg ci -m "backout the backout"
>
> Now from the view of hg, everything should work the same way as before
> (including later merges into default and later merges of default into
> vs-11.89).

That's a convoluted but smart way to work around the "we can't backout 
merge" core limitation of how DVCS dags work.

Currently the help says:

       Note:
        'hg backout' cannot be used to fix either an unwanted or
        incorrect merge.

Arne, would you mind provide a more detailed explanation of why backing 
out merge is problematic and how to execute your work around (and maybe 
even automate it withing the backout command, but I'm not too excited 
about that yet). That documentation update could be either on the wiki 
or directly in the inline help if  you find a non-scary way to put that 
down.

What do you think ?

-- 
Pierre-Yves David



More information about the Mercurial mailing list