Patchwork D11999: merge: consider the file merged when using :merge-{local, other}

login
register
mail settings
Submitter phabricator
Date Jan. 14, 2022, 5:48 p.m.
Message ID <differential-rev-PHID-DREV-eikuuz6wkaps275zb7ka-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50325/
State New
Headers show

Comments

phabricator - Jan. 14, 2022, 5:48 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Returning `None` from `simplemerge()` means that the caller interprets
  it as "no merge was necessary (because two sides matched)". See
  6217040b2780 <https://phab.mercurial-scm.org/rHG6217040b2780f42b892d64f0fcd601ab27b4f5d7> 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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED 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

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-merge-internal-tools-pattern.t b/tests/test-merge-internal-tools-pattern.t
--- a/tests/test-merge-internal-tools-pattern.t
+++ b/tests/test-merge-internal-tools-pattern.t
@@ -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
diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -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
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -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
diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -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
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -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