changeset 45469:49ffaa4f65f6

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
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 24 Aug 2020 17:22:28 +0530
parents 09edbff6ae8d
children 6e474eec4be6
files mercurial/merge.py tests/test-merge-criss-cross.t
diffstat 2 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Mon Aug 24 15:20:09 2020 +0530
+++ b/mercurial/merge.py	Mon Aug 24 17:22:28 2020 +0530
@@ -932,6 +932,14 @@
                     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
--- a/tests/test-merge-criss-cross.t	Mon Aug 24 15:20:09 2020 +0530
+++ b/tests/test-merge-criss-cross.t	Mon Aug 24 17:22:28 2020 +0530
@@ -431,6 +431,8 @@
   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 @@
   
   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 @@
   $ 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 @@
   $ 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