Backing out a merge - consequences?
Matt Mackall
mpm at selenic.com
Thu Jul 10 18:57:56 UTC 2014
On Thu, 2014-07-10 at 14:40 -0400, Tom Udale wrote:
> 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
> | |
You might want to instead mark the "do not use" branch head as closed
with:
hg commit --close-branch -m "do not use"
..which will avoid the aforementioned "confused merge" in the future.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list