Patchwork D12153: mergestate: use an early return for trivial merges

login
register
mail settings
Submitter phabricator
Date Feb. 8, 2022, 9:28 p.m.
Message ID <differential-rev-PHID-DREV-uevljrpzcvilzgatjsi2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50486/
State New
Headers show

Comments

phabricator - Feb. 8, 2022, 9:28 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `filemerge.filemerge()` returns `None` if no merge was needed because
  the two sides were identical. I'd like to move that to the
  caller. This is a little refactoring to prepare for that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/mergestate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -434,8 +434,11 @@ 
         if merge_ret is None:
             # If return value of merge is None, then there are no real conflict
             del self._state[dfile]
+            self._results[dfile] = None, None
             self._dirty = True
-        elif not merge_ret:
+            return None
+
+        if not merge_ret:
             self.mark(dfile, MERGE_RECORD_RESOLVED)
 
         action = None