# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-08-24 11:52:28 # Node ID 49ffaa4f65f6f53a79d52dcf4f36125ec8f4395c # Parent 09edbff6ae8d8a13c60529f1ee09f838041c9eb9 merge: add missing ACTION_KEEP when both remote and ancestor are not present Previous patch may lead to confusion that the related criss-cross merge is consistent when done from any of the parents. However this is not true and we were missing setting an ACTION_KEEP. This patch now exposes that bid-merge favors ACTION_KEEP always and the result of merge is different when started from different parents. This change also effects a test case above where bid merge was wrongly picking `r` because it was missing keep related information from one of the ancestor. After this test, we are back in a state in the criss-cross merge tests where the result depends on which parent we are merging from. Differential Revision: https://phab.mercurial-scm.org/D8941 diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -932,6 +932,14 @@ def manifestmerge( mresult.addfile( f, mergestatemod.ACTION_REMOVE, None, b'other deleted', ) + else: # file not in ancestor, not in remote + mresult.addfile( + f, + mergestatemod.ACTION_KEEP, + None, + b'ancestor missing, remote missing', + ) + elif n2: # file exists only on remote side if f in copied1: pass # we'll deal with it on m1 side diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t --- a/tests/test-merge-criss-cross.t +++ b/tests/test-merge-criss-cross.t @@ -431,6 +431,8 @@ Verify that the old context ancestor wor resolving manifests branchmerge: True, force: False, partial: False ancestor: 11b5b303e36c, local: c0ef19750a22+, remote: 6ca01f7342b9 + d1/a: ancestor missing, remote missing -> k + d1/b: ancestor missing, remote missing -> k d2/b: remote created -> g calculating bids for ancestor 154e6000f54e @@ -450,24 +452,24 @@ Verify that the old context ancestor wor auction for merging merge bids (2 ancestors) list of bids for d1/a: + ancestor missing, remote missing -> k other deleted -> r - d1/a: consensus for r + d1/a: picking 'keep' action list of bids for d1/b: + ancestor missing, remote missing -> k other deleted -> r - d1/b: consensus for r + d1/b: picking 'keep' action list of bids for d2/b: remote created -> g remote created -> g d2/b: consensus for g end of auction - d1/a: other deleted -> r - removing d1/a - d1/b: other deleted -> r - removing d1/b d2/b: remote created -> g getting d2/b - 1 files updated, 0 files merged, 2 files removed, 0 files unresolved + d1/a: ancestor missing, remote missing -> k + d1/b: ancestor missing, remote missing -> k + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) @@ -649,15 +651,16 @@ BROKEN: this should result in conflict $ hg update --clean 'desc("merge-keeping-the-file-from-updated")' 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge 'desc("merge-deleting-the-file-from-updated")' - 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ ls -1 other-file + the-file (merging two "keeping" together → no conflict) $ hg update --clean 'desc("merge-keeping-the-file-from-deleted")' - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge 'desc("merge-keeping-the-file-from-updated")' 0 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) @@ -683,7 +686,8 @@ BROKEN: this should result in conflict $ hg update --clean 'desc("merge-keeping-the-file-from-deleted")' 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge 'desc("merge-deleting-the-file-from-updated")' - 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ ls -1 other-file + the-file