changeset 45492:08c6d6962b2a

mergestate: split up reset() for its two use cases 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. Differential Revision: https://phab.mercurial-scm.org/D9033
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 16 Sep 2020 10:09:37 -0700
parents aad11a26a054
children 2c10876bb320
files mercurial/mergestate.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mergestate.py	Tue Sep 15 23:19:14 2020 -0700
+++ b/mercurial/mergestate.py	Wed Sep 16 10:09:37 2020 -0700
@@ -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