changeset 48594:50de08904c63

merge: consider the file merged when using :merge-{local,other} Returning `None` from `simplemerge()` means that the caller interprets it as "no merge was necessary (because two sides matched)". See 6217040b2780 and issue2680 for some background. However, `simplemerge()` shouldn't even get called in such scenarios, and returning `None` means that the file is not considered merged, even though the contents actually were. See the affected test cases. Differential Revision: https://phab.mercurial-scm.org/D11999
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 14 Jan 2022 09:28:44 -0800
parents 7ed4c4753891
children d1210d56008b
files mercurial/simplemerge.py tests/test-annotate.t tests/test-conflict.t tests/test-copies-chain-merge.t tests/test-merge-internal-tools-pattern.t
diffstat 5 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/simplemerge.py	Fri Jan 14 08:44:36 2022 -0800
+++ b/mercurial/simplemerge.py	Fri Jan 14 09:28:44 2022 -0800
@@ -483,7 +483,7 @@
         basetext = readctx(basectx)
         othertext = readctx(otherctx)
     except error.Abort:
-        return 1
+        return True
 
     m3 = Merge3Text(basetext, localtext, othertext)
     conflicts = False
@@ -511,5 +511,4 @@
         # mergestate.resolve())
         localctx.write(mergedtext, localctx.flags())
 
-    if conflicts:
-        return 1
+    return conflicts
--- a/tests/test-annotate.t	Fri Jan 14 08:44:36 2022 -0800
+++ b/tests/test-annotate.t	Fri Jan 14 09:28:44 2022 -0800
@@ -886,7 +886,7 @@
   created new head
   $ hg merge --tool :merge-other 24
   merging baz
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m 'merge forgetting about baz rewrite'
   $ cat > baz << EOF
--- a/tests/test-conflict.t	Fri Jan 14 08:44:36 2022 -0800
+++ b/tests/test-conflict.t	Fri Jan 14 09:28:44 2022 -0800
@@ -404,7 +404,7 @@
   1 other heads for branch "default"
   $ hg merge --tool :merge-local
   merging a
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ cat a
   Start of file
--- a/tests/test-copies-chain-merge.t	Fri Jan 14 08:44:36 2022 -0800
+++ b/tests/test-copies-chain-merge.t	Fri Jan 14 09:28:44 2022 -0800
@@ -463,14 +463,14 @@
   3 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg merge 'desc("q-2")' --tool ':union'
   merging v
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  0 files updated, 1 files merged, 1 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m "mPQm-0 $case_desc - one way"
   $ hg up 'desc("q-2")'
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge 'desc("p-2")' --tool ':union'
   merging v
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  0 files updated, 1 files merged, 1 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m "mQPm-0 $case_desc - the other way"
   created new head
@@ -626,14 +626,14 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge 'desc("g-1")' --tool :union
   merging d
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m "mDGm-0 $case_desc - one way"
   $ hg up 'desc("g-1")'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg merge 'desc("d-2")' --tool :union
   merging d
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m "mGDm-0 $case_desc - the other way"
   created new head
--- a/tests/test-merge-internal-tools-pattern.t	Fri Jan 14 08:44:36 2022 -0800
+++ b/tests/test-merge-internal-tools-pattern.t	Fri Jan 14 09:28:44 2022 -0800
@@ -130,7 +130,7 @@
 
   $ hg merge 3
   merging f
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
 
   $ cat f