Mercurial > hg-stable
changeset 19928:d1ac3790e10a
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 17 Oct 2013 21:45:17 +0900 |
parents | 76c83107a724 |
children | ab2362e1672e |
files | hgext/largefiles/__init__.py mercurial/localrepo.py |
diffstat | 2 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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