diff mercurial/localrepo.py @ 37135:ecac0006b90e

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 20 Mar 2018 17:30:30 -0700
parents a8a902d7176e
children db90a5793103
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Mar 04 17:11:33 2018 -0500
+++ b/mercurial/localrepo.py	Tue Mar 20 17:30:30 2018 -0700
@@ -309,6 +309,15 @@
 # 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 @@
         '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 @@
         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: