Merge revert

André Felipe Dias andref.dias at gmail.com
Tue Oct 4 12:27:11 UTC 2016


Hi, Nicolas

 > On 4 Oct. 2016, at 1:22 am, Nicolas Pinault <nicolasp at aaton.com> 
wrote:
 >
 > Hi,
 >
 > I accidentally merged 2 branches. Before I realize it I committed 
changes and pushed to the server.
 > When I try to backout the merge node, I get : "abandon : cannot 
backout a merge changeset"
 > What is the best way to correct this error ?
 >
 > Nicolas
 > _______________________________________________
 > Mercurial mailing list
 > Mercurial at mercurial-scm.org
 > https://www.mercurial-scm.org/mailman/listinfo/mercurial


hg backout used to backout a merge changeset at Mercurial 2.8 (I guess) 
although it was already marked as depracated by then. It's a pity that 
this was removed. I think it should warn about the fully implications of 
this kind of backout but keep the behavior or use some --force flag.

I fully understand  that a backout of a merge changeset is not just it. 
This topic has already been discussed in this list (see posts around 
2013-05-17), but I still believe that sometimes this is the only 
solution. Other interesting links about the topics are: 
https://git-scm.com/blog/2010/03/02/undoing-merges.html and
http://schacon.github.io/git/howto/revert-a-faulty-merge.txt

So, I suggest two alternatives:

1. Downgrade Mecurial do a earlier version, do the backout and upgrade back
2. _or_ Execute the equivalent steps of a backout:

     CURRENT_REV=$(hg id -i)
     hg update -C -r $MERGE_CHANGESET_TO_BACKOUT
     hg revert --all -r .^1
     hg update -r $CURRENT_REV

Regards,

André



More information about the Mercurial mailing list