Backing out a merge - consequences?

Tom Udale tom at ionoptix.com
Thu Jul 10 18:40:46 UTC 2014


Hi Matt,

>> We have a situation where a feature branch was inappropriately merged
>> (and pushed, of course) into the default branch.
>>
>> I have on my local machine run
>>
>> hg backout -r 1234 --parent 1233
>>
>> which has dutifully put my local repo back at the state of rev 1233.
>
> The "backing out a merge" behavior was so broken, we deprecated it in
> 2011. Don't use it.
>
> While it has the desired effect on the _contents_ of your changeset, it
> can't unrecord that a merge happened in your history graph. Since the
> merge is still there, but with a "null" result, future merges will be
> confused and dutifully undo the same changes.

I had a feeling something like this was afoot.



> To fix it, you need to commit a correct merge above the backed-out merge
> and force all users to update past it so that future merges won't be
> confused.

This is what I have:

   o           1234 default - "premature merge w\feature"
   |\
   o \         1233 default
   |  \
   |   o       1232 feature
   |   |


If I understand what you are suggesting, you are saying to do something 
like this:


|   o           1236 default - tag "DO NOT Use Me!!"
o   |           1235 default - tag "Use Me!!"
  \  |
   \ o           1234 default - "premature merge w\feature"
    \|\
     o \         1233 default
     |  \
     |   o       1232 feature
     |   |


And push with a -f to handle the creation of two heads on default.

Then much later when we _actually_ do want to merge the feature branch 
in, we can merge the two default branches together and then merge in the 
new feature branch changesets like so:



o               1401 default "merge in rest of feature"
|\
| \
|  \
|   \
|    \
o     \         1400 default "merge in old premature merge".
|\     \
| \     o       1399 feature "final feature fixes"
|  \    |
~~~~~~~~~

...other changes

~~~~~~~~~
|   o   |       1236 default - tag "DO NOT Use Me!!"
o   |   |       1235 default - tag "Use Me!!"
  \  |   |
   \ o   |       1234 default - "premature merge w\feature"
    \|\  |
     o \ |       1233 default
     |  \|
     |   o       1232 feature
     |   |



Of course, the reason to merge in the old premature merge is simply to 
get default back to one head.


Is that a reasonable plan?

Best regards,

Tom





More information about the Mercurial mailing list