Patchwork D9035: mergestate: move most of of reset() into start()

login
register
mail settings
Submitter phabricator
Date Sept. 17, 2020, 8:11 p.m.
Message ID <differential-rev-PHID-DREV-m54h56y3agu4rzwjs3wc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47194/
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
  `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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -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