[Request] [+- ] D8941: merge: add missing ACTION_KEEP when both remote and ancestor are not present

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Aug 24 14:15:17 UTC 2020


pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8941

AFFECTED FILES
  mercurial/merge.py
  tests/test-merge-criss-cross.t

CHANGE DETAILS

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
@@ -413,6 +413,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
@@ -431,18 +433,16 @@
    d2/b: remote created -> g
   
   auction for merging merge bids
-   d1/a: consensus for r
-   d1/b: consensus for r
+   d1/a: picking 'keep' action
+   d1/b: picking 'keep' action
    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)
 
 Testing that whether a new filenode is created or not
@@ -533,14 +533,15 @@
   
 We should prompt instead of silently choosing a side here
   $ hg merge 411bc7ca43bc
-  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
   bar
+  foo
 
 We should prompt instead of silently choosing a side here
   $ hg co 411bc7ca43bc -C
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg merge 9c9dbcbc1e03
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -928,6 +928,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



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200824/51ef5968/attachment-0001.html>


More information about the Mercurial-patches mailing list