How to recover after criss-cross merge?
Mads Kiilerich
mads at kiilerich.com
Sun Jan 17 23:02:06 UTC 2016
On 01/13/2016 10:06 PM, Manuel Jacob wrote:
> Hi,
>
> In the PyPy repository [1] we have three branches (which are
> interesting for this post): "default", "py3k", "py3.3". "py3k"
> branched from "default" and we regularly merge "default" into "py3k".
> "py3.3" branched from "py3k" and we regularly merge "py3k" into "py3.3".
>
> Everything worked fine until someone merged directly from "default" to
> "py3.3" (changeset 4fa19970ddeb), skipping "py3k". When merging from
> "py3k" into "py3.3" the next time (changeset 88aafcb7c318) we ran into
> problems. It showed many "ambiguous merge - picked m action"
> warnings. Also, some files (e.g. lib-python/3/_abcoll.py) which were
> removed in the "py3.3" branch (but still existent in "py3k")
> re-appeared without warning.
>
> A possible solution is to close the current "py3.3" branch head and
> redo (i.e. grafting or rebasing with --keep) all changes from just
> before the merge from "default" into "py3.3" (except the problematic
> merge itself).
>
> I'd prefer to only redo all changes from just before the merge from
> "py3k" into "py3.3". I tested (locally) redoing this merge (changeset
> 88aafcb7c318) with aeafe30eac60 as a merge base (by passing "--config
> merge.preferancestor=aeafe30eac60"). This changeset aeafe30eac60 is
> the last commit from "py3k" which got merged into "py3.3" before
> 88aafcb7c318. It seems to do exactly what I want.
Fine. It seems like it hasn't been committed yet?
I suggest redoing and committing it this way:
hg up -C -r 88aafcb7c318^
hg merge 88aafcb7c318^2 --config merge.preferancestor=aeafe30eac60
(a change/delete conflict and 9 regular conflicts)
hg ci -m 'Redo 88aafcb7c318: hg merge py3k (+ fixes)'
hg merge 88aafcb7c318
hg revert -a -r .
hg ci -m 'Merge and annihilate 88aafcb7c318'
hg heads py3.3
hg merge 26dd3a53c0c4
hg ci -m 'Merge with reworked 88aafcb7c318'
hg diff -r .^2 --stat
(review what this whole operation changed on top of the old py3.3 head)
Try it out and review it carefully locally ... and fix my mistakes.
> However the next time I merged "py3k" into "py3.3" (after in turn
> merging "default" into "py3k") I ran into problems again (ambiguous
> merge warnings and re-appearing files). Is there a way to permanently
> fix the problem?
That is the same problem for another reason. more-rposix was merged to
default in
0fec717553f0 2015-12-13 ronan.lamy at gmail.com "Merged in more-rposix
(pull request #365)"
and to py3.3 in
7d4ae17b382a 2015-06-25 amauryfa at gmail.com "hg merge more-rposix,
directly in py3.3 branch."
If you add '-v' when merging, you will get an initial message
note: merging 26dd3a53c0c4+ and a248ed4650dc using bids from ancestors
6da866a9e7d5 and f4d30da9a715
and I guess you will have to use 6da866a9e7d5 as ancestor.
In https://selenic.com/hg/rev/16a46003b50c we made this "here be
dragons" message less visible. It should perhaps instead be rephrased
and made more visible? The problem is that it is impossible to explain
what the problem is and what action the user should take ... and often
it works ok anyway and a warning cause more trouble.
Or would it perhaps be better if the merge aborted if there were any
ambiguous conflicting bids at all?
/Mads
More information about the Mercurial
mailing list