# HG changeset patch # User Jun Wu # Date 1487216474 28800 # Node ID 74af89c6683474fd54962e77574dde661b5837a0 # Parent d194f0dba7ac9aad7d4c355e1ffe94168dfd24c2 localrepo: move extension loading to a separate method The stateful chg plan [1] requires a special repo object, where ideally all side effects caused by loading the repo object could be reverted by just dropping (gabbage collect) the loaded repo object. Currently, that is impossible because repo.__init__ calls "extensions.loadall", which may have unpredictable side-effects that cannot be reverted by dropping the repo object. This patch moves "extensions.loadall" to a separate method, so chg could subclass localrepository and make extensions loading a no-op. [1]: mercurial-scm.org/pipermail/mercurial-devel/2017-February/092547.html diff -r d194f0dba7ac -r 74af89c66834 mercurial/localrepo.py --- a/mercurial/localrepo.py Thu Feb 16 17:30:35 2017 +0530 +++ b/mercurial/localrepo.py Wed Feb 15 19:41:14 2017 -0800 @@ -270,7 +270,7 @@ self._phasedefaults = [] try: self.ui.readconfig(self.join("hgrc"), self.root) - extensions.loadall(self.ui) + self._loadextensions() except IOError: pass @@ -371,6 +371,9 @@ def close(self): self._writecaches() + def _loadextensions(self): + extensions.loadall(self.ui) + def _writecaches(self): if self._revbranchcache: self._revbranchcache.write()