From patchwork Thu Sep 17 20:11:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9033: mergestate: split up reset() for its two use cases From: phabricator X-Patchwork-Id: 47193 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Thu, 17 Sep 2020 20:11:03 +0000 martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY 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. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9033 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 @@ -181,7 +181,8 @@ """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 @@ 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 @@ 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