# HG changeset patch # User FUJIWARA Katsunori # Date 1382013917 -32400 # Node ID d1ac3790e10a44a3e55e7fe2a86e3e2a849382e9 # Parent 76c83107a724ce6069098075427575f665f01a7f localrepo: invoke only feature setup functions for enabled extensions Before this patch, each feature setup functions for localrepository class should examine whether corresponding extension is enabled or not by themselves. This patch invokes only feature setup functions defined in module of enabled extensions, and it makes implementation of feature setup functions easier and simpler. diff -r 76c83107a724 -r d1ac3790e10a hgext/largefiles/__init__.py --- a/hgext/largefiles/__init__.py Wed Oct 02 21:16:40 2013 +0900 +++ b/hgext/largefiles/__init__.py Thu Oct 17 21:45:17 2013 +0900 @@ -105,7 +105,7 @@ command. ''' -from mercurial import commands, localrepo, extensions +from mercurial import commands, localrepo import lfcommands import reposetup @@ -116,11 +116,8 @@ reposetup = reposetup.reposetup def featuresetup(ui, supported): - for name, module in extensions.extensions(ui): - if __name__ == module.__name__: - # don't die on seeing a repo with the largefiles requirement - supported |= set(['largefiles']) - return + # don't die on seeing a repo with the largefiles requirement + supported |= set(['largefiles']) def uisetup(ui): localrepo.localrepository.featuresetupfuncs.add(featuresetup) diff -r 76c83107a724 -r d1ac3790e10a mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Oct 02 21:16:40 2013 +0900 +++ b/mercurial/localrepo.py Thu Oct 17 21:45:17 2013 +0900 @@ -153,6 +153,8 @@ requirements = ['revlogv1'] filtername = None + # a list of (ui, featureset) functions. + # only functions defined in module of enabled extensions are invoked featuresetupfuncs = set() def _baserequirements(self, create): @@ -181,8 +183,11 @@ if self.featuresetupfuncs: self.supported = set(self._basesupported) # use private copy + extmods = set(m.__name__ for n, m + in extensions.extensions(self.ui)) for setupfunc in self.featuresetupfuncs: - setupfunc(self.ui, self.supported) + if setupfunc.__module__ in extmods: + setupfunc(self.ui, self.supported) else: self.supported = self._basesupported