Patchwork D9033: mergestate: split up reset() for its two use cases

login
register
mail settings
Submitter phabricator
Date Sept. 17, 2020, 8:11 p.m.
Message ID <differential-rev-PHID-DREV-ezemwyxv6ifpzt4gjsd3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47193/
State Superseded
Headers show

Comments

phabricator - Sept. 17, 2020, 8:11 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We only have one place that calls `ms.reset()` with any
  arguments. That place is `mergestate.clean()`. The callers that call
  the function with no arguments seem to all just want delete the
  mergestate -- none of them look at the instance after calling
  `reset()`. Let's separate out the two different use cases to make the
  code clearer. I'll clean up further soon.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -181,7 +181,8 @@ 
         """Initialize a brand new merge state, removing any existing state on
         disk."""
         ms = mergestate(repo)
-        ms.reset(node, other, labels)
+        ms.reset()
+        ms.start(node, other, labels)
         return ms
 
     @staticmethod
@@ -199,12 +200,9 @@ 
         self._dirty = False
         self._labels = None
 
-    def reset(self, node=None, other=None, labels=None):
+    def reset(self):
         self._state = {}
         self._stateextras = collections.defaultdict(dict)
-        self._local = node
-        self._other = other
-        self._labels = labels
         for var in ('localctx', 'otherctx'):
             if var in vars(self):
                 delattr(self, var)
@@ -217,6 +215,11 @@ 
         self._results = {}
         self._dirty = False
 
+    def start(self, node, other, labels=None):
+        self._local = node
+        self._other = other
+        self._labels = labels
+
     def _read(self):
         """Analyse each record content to restore a serialized state from disk