From patchwork Thu Sep 17 20:11:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9035: mergestate: move most of of reset() into start() From: phabricator X-Patchwork-Id: 47194 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Thu, 17 Sep 2020 20:11:04 +0000 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 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