changeset 39563:41aa5dced975

localrepo: pass ui to newreporequirements() (API) newreporequirements() is called as part of creating a new repository. It doesn't make much sense for it to receive a repo instance as part of determining what requirements for new repos should be. .. api:: localrepo.newreporequirements() receives a ui instead of a repo Differential Revision: https://phab.mercurial-scm.org/D4533
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 07 Sep 2018 15:57:55 -0700
parents 4afd2af36456
children 7ce9dea3a14a
files mercurial/localrepo.py mercurial/upgrade.py tests/simplestorerepo.py
diffstat 3 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Sep 11 15:40:33 2018 -0700
+++ b/mercurial/localrepo.py	Fri Sep 07 15:57:55 2018 -0700
@@ -476,7 +476,7 @@
 
         if not self.vfs.isdir():
             if create:
-                self.requirements = newreporequirements(self)
+                self.requirements = newreporequirements(self.ui)
 
                 if not self.wvfs.exists():
                     self.wvfs.makedirs()
@@ -2402,13 +2402,12 @@
 def islocal(path):
     return True
 
-def newreporequirements(repo):
+def newreporequirements(ui):
     """Determine the set of requirements for a new local repository.
 
     Extensions can wrap this function to specify custom requirements for
     new repositories.
     """
-    ui = repo.ui
     requirements = {'revlogv1'}
     if ui.configbool('format', 'usestore'):
         requirements.add('store')
@@ -2444,7 +2443,7 @@
         requirements.discard('generaldelta')
         requirements.add(REVLOGV2_REQUIREMENT)
     # experimental config: format.internal-phase
-    if repo.ui.configbool('format', 'internal-phase'):
+    if ui.configbool('format', 'internal-phase'):
         requirements.add('internal-phase')
 
     return requirements
--- a/mercurial/upgrade.py	Tue Sep 11 15:40:33 2018 -0700
+++ b/mercurial/upgrade.py	Fri Sep 07 15:57:55 2018 -0700
@@ -198,8 +198,8 @@
     _requirement = None
 
     @staticmethod
-    def _newreporequirements(repo):
-        return localrepo.newreporequirements(repo)
+    def _newreporequirements(ui):
+        return localrepo.newreporequirements(ui)
 
     @classmethod
     def fromrepo(cls, repo):
@@ -209,7 +209,7 @@
     @classmethod
     def fromconfig(cls, repo):
         assert cls._requirement is not None
-        return cls._requirement in cls._newreporequirements(repo)
+        return cls._requirement in cls._newreporequirements(repo.ui)
 
 @registerformatvariant
 class fncache(requirementformatvariant):
@@ -751,7 +751,7 @@
 
     # FUTURE there is potentially a need to control the wanted requirements via
     # command arguments or via an extension hook point.
-    newreqs = localrepo.newreporequirements(repo)
+    newreqs = localrepo.newreporequirements(repo.ui)
     newreqs.update(preservedrequirements(repo))
 
     noremovereqs = (repo.requirements - newreqs -
--- a/tests/simplestorerepo.py	Tue Sep 11 15:40:33 2018 -0700
+++ b/tests/simplestorerepo.py	Fri Sep 07 15:57:55 2018 -0700
@@ -712,9 +712,9 @@
 def featuresetup(ui, supported):
     supported.add(REQUIREMENT)
 
-def newreporequirements(orig, repo):
+def newreporequirements(orig, ui):
     """Modifies default requirements for new repos to use the simple store."""
-    requirements = orig(repo)
+    requirements = orig(ui)
 
     # These requirements are only used to affect creation of the store
     # object. We have our own store. So we can remove them.