mergestate: remove unnecessary clearing of `localctx` and `otherctx`
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 17 Sep 2020 19:33:55 -0700
changeset 45506 3dd481e11c25
parent 45505 9ea4b52ac6bb
child 45507 ef3273ac5f6e
mergestate: remove unnecessary clearing of `localctx` and `otherctx` As noted in the previous commit, there are no callers that (re-)use the instance after calling `reset()`. There are also no callers that call `_read()` after doing anything with the instance (it's only called right after an instance is created). If reviewers feel that this is too risky, I can extract and reuse the poisoning code that indygreg once added for poisining repo instances. Differential Revision: https://phab.mercurial-scm.org/D9036
mercurial/mergestate.py
--- a/mercurial/mergestate.py	Wed Sep 16 13:25:49 2020 -0700
+++ b/mercurial/mergestate.py	Thu Sep 17 19:33:55 2020 -0700
@@ -12,7 +12,6 @@
     nullhex,
     nullid,
 )
-from .pycompat import delattr
 from . import (
     error,
     filemerge,
@@ -208,9 +207,6 @@
         self._labels = labels
         self._state = {}
         self._stateextras = collections.defaultdict(dict)
-        for var in ('localctx', 'otherctx'):
-            if var in vars(self):
-                delattr(self, var)
         self._readmergedriver = None
         if self.mergedriver:
             self._mdstate = MERGE_DRIVER_STATE_SUCCESS
@@ -229,9 +225,6 @@
         self._stateextras = collections.defaultdict(dict)
         self._local = None
         self._other = None
-        for var in ('localctx', 'otherctx'):
-            if var in vars(self):
-                delattr(self, var)
         self._readmergedriver = None
         self._mdstate = MERGE_DRIVER_STATE_SUCCESS
         unsupported = set()