D11885: filemerge: stop returning always-`True` value

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Wed Dec 8 05:56:58 UTC 2021


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

REVISION SUMMARY
  Now that we've removed some more leftovers from "merge driver", it's
  clear that the first element of `filemerge()`'s return value is always
  `True`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/largefiles/overrides.py
  mercurial/filemerge.py
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -354,7 +354,7 @@
             self._restore_backup(wctx[dfile], localkey, flags)
         else:
             wctx[dfile].remove(ignoremissing=True)
-        complete, merge_ret, deleted = filemerge.filemerge(
+        merge_ret, deleted = filemerge.filemerge(
             self._repo,
             wctx,
             self._local,
@@ -371,26 +371,25 @@
         elif not merge_ret:
             self.mark(dfile, MERGE_RECORD_RESOLVED)
 
-        if complete:
-            action = None
-            if deleted:
-                if fcd.isabsent():
-                    # dc: local picked. Need to drop if present, which may
-                    # happen on re-resolves.
-                    action = ACTION_FORGET
+        action = None
+        if deleted:
+            if fcd.isabsent():
+                # dc: local picked. Need to drop if present, which may
+                # happen on re-resolves.
+                action = ACTION_FORGET
+            else:
+                # cd: remote picked (or otherwise deleted)
+                action = ACTION_REMOVE
+        else:
+            if fcd.isabsent():  # dc: remote picked
+                action = ACTION_GET
+            elif fco.isabsent():  # cd: local picked
+                if dfile in self.localctx:
+                    action = ACTION_ADD_MODIFIED
                 else:
-                    # cd: remote picked (or otherwise deleted)
-                    action = ACTION_REMOVE
-            else:
-                if fcd.isabsent():  # dc: remote picked
-                    action = ACTION_GET
-                elif fco.isabsent():  # cd: local picked
-                    if dfile in self.localctx:
-                        action = ACTION_ADD_MODIFIED
-                    else:
-                        action = ACTION_ADD
-                # else: regular merges (no action necessary)
-            self._results[dfile] = merge_ret, action
+                    action = ACTION_ADD
+            # else: regular merges (no action necessary)
+        self._results[dfile] = merge_ret, action
 
         return merge_ret
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -1032,7 +1032,7 @@
     a boolean indicating whether the file was deleted from disk."""
 
     if not fco.cmp(fcd):  # files identical?
-        return True, None, False
+        return None, False
 
     ui = repo.ui
     fd = fcd.path()
@@ -1090,8 +1090,7 @@
     toolconf = tool, toolpath, binary, symlink, scriptfn
 
     if mergetype == nomerge:
-        r, deleted = func(repo, mynode, fcd, fco, fca, toolconf, labels)
-        return True, r, deleted
+        return func(repo, mynode, fcd, fco, fca, toolconf, labels)
 
     if orig != fco.path():
         ui.status(
@@ -1110,7 +1109,7 @@
                     b'in-memory merge does not support merge conflicts'
                 )
             ui.warn(onfailure % fduipath)
-        return True, 1, False
+        return 1, False
 
     backup = _makebackup(repo, ui, wctx, fcd)
     r = 1
@@ -1151,7 +1150,7 @@
             )
             # we're done if premerge was successful (r is 0)
             if not r:
-                return not r, r, False
+                return r, False
 
         needcheck, r, deleted = func(
             repo,
@@ -1178,7 +1177,7 @@
                 ui.warn(onfailure % fduipath)
             _onfilemergefailure(ui)
 
-        return True, r, deleted
+        return r, deleted
     finally:
         if not r and backup is not None:
             backup.remove()
diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -695,7 +695,7 @@
         )
     ):
         repo.wwrite(fcd.path(), fco.data(), fco.flags())
-    return True, 0, False
+    return 0, False
 
 
 @eh.wrapfunction(copiesmod, b'pathcopies')



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


More information about the Mercurial-devel mailing list