# HG changeset patch # User Martin von Zweigbergk # Date 2020-09-16 17:09:37 # Node ID 08c6d6962b2ac15bf4cb205e4cbc0c9e3109bff1 # Parent aad11a26a054f7d90e72a726ac2a95e37959a9f0 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 diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py --- a/mercurial/mergestate.py +++ b/mercurial/mergestate.py @@ -181,7 +181,8 @@ class mergestate(object): """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 @@ class mergestate(object): 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 @@ class mergestate(object): 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