# HG changeset patch # User Martin von Zweigbergk # Date 2020-09-16 20:25:49 # Node ID 9ea4b52ac6bb0513e896db023dbcc766bfa754a8 # Parent 2c10876bb320f33b2807938774aeef681d2c2453 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 diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py --- a/mercurial/mergestate.py +++ b/mercurial/mergestate.py @@ -200,6 +200,12 @@ class mergestate(object): 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 @@ class mergestate(object): 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