# HG changeset patch # User Gregory Szorc # Date 2018-03-21 00:30:30 # Node ID ecac0006b90ee526def300f327accf97d1ef396c # Parent 6890b7e991a4c7cf9de095247523a17cb24ecba8 localrepo: move featuresetupfuncs out of localrepository class (API) I want to establish an interface for local repositories. featuresetupfuncs is a class attribute and is global/shared across all localrepository instances. Let's move it to a module-level attribute to clarify it isn't part of the local repository interface. .. api:: localrepo.localrepository.featuresetupfuncs has been renamed to localrepo.featuresetupfuncs. Differential Revision: https://phab.mercurial-scm.org/D2925 diff --git a/hgext/largefiles/__init__.py b/hgext/largefiles/__init__.py --- a/hgext/largefiles/__init__.py +++ b/hgext/largefiles/__init__.py @@ -146,7 +146,7 @@ def featuresetup(ui, supported): supported |= {'largefiles'} def uisetup(ui): - localrepo.localrepository.featuresetupfuncs.add(featuresetup) + localrepo.featuresetupfuncs.add(featuresetup) hg.wirepeersetupfuncs.append(proto.wirereposetup) uisetupmod.uisetup(ui) diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py --- a/hgext/lfs/__init__.py +++ b/hgext/lfs/__init__.py @@ -199,7 +199,7 @@ def featuresetup(ui, supported): supported |= {'lfs'} def uisetup(ui): - localrepo.localrepository.featuresetupfuncs.add(featuresetup) + localrepo.featuresetupfuncs.add(featuresetup) def reposetup(ui, repo): # Nothing to do with a remote repo diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -309,6 +309,15 @@ class locallegacypeer(repository.legacyp # clients. REVLOGV2_REQUIREMENT = 'exp-revlogv2.0' +# Functions receiving (ui, features) that extensions can register to impact +# the ability to load repositories with custom requirements. Only +# functions defined in loaded extensions are called. +# +# The function receives a set of requirement strings that the repository +# is capable of opening. Functions will typically add elements to the +# set to reflect that the extension knows how to handle that requirements. +featuresetupfuncs = set() + class localrepository(object): # obsolete experimental requirements: @@ -336,10 +345,6 @@ class localrepository(object): 'treemanifest', } - # a list of (ui, featureset) functions. - # only functions defined in module of enabled extensions are invoked - featuresetupfuncs = set() - # list of prefix for file which can be written without 'wlock' # Extensions should extend this list when needed _wlockfreeprefix = { @@ -399,11 +404,11 @@ class localrepository(object): except IOError: pass - if self.featuresetupfuncs: + if 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: + for setupfunc in featuresetupfuncs: if setupfunc.__module__ in extmods: setupfunc(self.ui, self.supported) else: diff --git a/tests/test-requires.t b/tests/test-requires.t --- a/tests/test-requires.t +++ b/tests/test-requires.t @@ -41,7 +41,7 @@ another repository of push/pull/clone on > supported |= {'featuresetup-test'} > return > def uisetup(ui): - > localrepo.localrepository.featuresetupfuncs.add(featuresetup) + > localrepo.featuresetupfuncs.add(featuresetup) > EOF $ cat > supported/.hg/hgrc < [extensions]