mergestate: move most of of reset() into start()
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 16 Sep 2020 13:25:49 -0700
changeset 45494 9ea4b52ac6bb
parent 45493 2c10876bb320
child 45495 3dd481e11c25
mergestate: move most of of reset() into start() `ms.reset()` has somehow become a combination of two different things: 1. A constructor-like function creating an empty instance 2. A call to `shutil.rmtree()` to clear the mergestate. It seems that all callers now care only about the latter (since we changed one caller to use the new `ms.start()` method instead). Let's move the code for the former into `start()`, since that's the only place it's needed. Differential Revision: https://phab.mercurial-scm.org/D9035
mercurial/mergestate.py
--- a/mercurial/mergestate.py	Thu Sep 17 09:23:21 2020 -0700
+++ b/mercurial/mergestate.py	Wed Sep 16 13:25:49 2020 -0700
@@ -200,6 +200,12 @@
         self._labels = None
 
     def reset(self):
+        shutil.rmtree(self._repo.vfs.join(b'merge'), True)
+
+    def start(self, node, other, labels=None):
+        self._local = node
+        self._other = other
+        self._labels = labels
         self._state = {}
         self._stateextras = collections.defaultdict(dict)
         for var in ('localctx', 'otherctx'):
@@ -210,15 +216,9 @@
             self._mdstate = MERGE_DRIVER_STATE_SUCCESS
         else:
             self._mdstate = MERGE_DRIVER_STATE_UNMARKED
-        shutil.rmtree(self._repo.vfs.join(b'merge'), True)
         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