Patchwork D11856: mergestate: make `_resolve()` do both preresolve and resolve

login
register
mail settings
Submitter phabricator
Date Dec. 4, 2021, 7:06 a.m.
Message ID <differential-rev-PHID-DREV-fd3vhc3jsndqvkjpnj5f-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50181/
State Superseded
Headers show

Comments

phabricator - Dec. 4, 2021, 7:06 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This patch removes the `preresolve` argument from `_resolve()` and
  makes it do both the "preresolve" and "resolve" steps without the
  caller having to call it twice.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -313,16 +313,15 @@ 
         """return extras stored with the mergestate for the given filename"""
         return self._stateextras[filename]
 
-    def _resolve(self, preresolve, dfile, wctx):
+    def _resolve(self, dfile, wctx):
         """rerun merge process for file path `dfile`.
-        Returns whether the merge was completed and the return value of merge
-        obtained from filemerge._filemerge().
+        Returns the return value of merge obtained from filemerge._filemerge().
         """
         if self[dfile] in (
             MERGE_RECORD_RESOLVED,
             LEGACY_RECORD_DRIVER_RESOLVED,
         ):
-            return True, 0
+            return 0
         stateentry = self._state[dfile]
         state, localkey, lfile, afile, anode, ofile, onode, flags = stateentry
         octx = self._repo[self._other]
@@ -341,33 +340,31 @@ 
         fla = fca.flags()
         if b'x' in flags + flo + fla and b'l' not in flags + flo + fla:
             if fca.rev() == nullrev and flags != flo:
-                if preresolve:
-                    self._repo.ui.warn(
-                        _(
-                            b'warning: cannot merge flags for %s '
-                            b'without common ancestor - keeping local flags\n'
-                        )
-                        % afile
+                self._repo.ui.warn(
+                    _(
+                        b'warning: cannot merge flags for %s '
+                        b'without common ancestor - keeping local flags\n'
                     )
+                    % afile
+                )
             elif flags == fla:
                 flags = flo
-        if preresolve:
-            # restore local
-            if localkey != self._repo.nodeconstants.nullhex:
-                self._restore_backup(wctx[dfile], localkey, flags)
-            else:
-                wctx[dfile].remove(ignoremissing=True)
-            complete, merge_ret, deleted = filemerge.premerge(
-                self._repo,
-                wctx,
-                self._local,
-                lfile,
-                fcd,
-                fco,
-                fca,
-                labels=self._labels,
-            )
+        # restore local
+        if localkey != self._repo.nodeconstants.nullhex:
+            self._restore_backup(wctx[dfile], localkey, flags)
         else:
+            wctx[dfile].remove(ignoremissing=True)
+        complete, merge_ret, deleted = filemerge.premerge(
+            self._repo,
+            wctx,
+            self._local,
+            lfile,
+            fcd,
+            fco,
+            fca,
+            labels=self._labels,
+        )
+        if not complete:
             complete, merge_ret, deleted = filemerge.filemerge(
                 self._repo,
                 wctx,
@@ -406,16 +403,13 @@ 
                 # else: regular merges (no action necessary)
             self._results[dfile] = merge_ret, action
 
-        return complete, merge_ret
+        return merge_ret
 
     def resolve(self, dfile, wctx):
         """run merge process for dfile
 
         Returns the exit code of the merge."""
-        complete, r = self._resolve(True, dfile, wctx)
-        if not complete:
-            r = self._resolve(False, dfile, wctx)[1]
-        return r
+        return self._resolve(dfile, wctx)
 
     def counts(self):
         """return counts for updated, merged and removed files in this