Patchwork [05,of,10] localrepo: move supported to baselocalrepository

login
register
mail settings
Submitter Jun Wu
Date Feb. 10, 2017, 1:46 a.m.
Message ID <76448b71f139b1fa06f2.1486691179@localhost.localdomain>
Download mbox | patch
Permalink /patch/18379/
State Deferred
Headers show

Comments

Jun Wu - Feb. 10, 2017, 1:46 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1486689390 28800
#      Thu Feb 09 17:16:30 2017 -0800
# Node ID 76448b71f139b1fa06f2dbce04ac3f91ffd93f9d
# Parent  5e47a19fae82f4659f1e7df37f8f26dd56c4f246
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 76448b71f139
localrepo: move supported to baselocalrepository

See the previous patch for why.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -247,4 +247,10 @@  class baselocalrepository(object):
     repo states, without causing unwanted effects.
     """
+
+    supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest',
+                            'manifestv2'))
+    _basesupported = supportedformats | set(('store', 'fncache', 'shared',
+                                             'dotencode'))
+
     def __init__(self, baseui, path):
         self.requirements = set()
@@ -266,4 +272,6 @@  class baselocalrepository(object):
             pass
 
+        self.supported = self._loadsupported()
+
     def _loadextensions(self):
         # baselocalrepository is side-effect free, so "loading extensions" is a
@@ -271,4 +279,8 @@  class baselocalrepository(object):
         pass
 
+    def _loadsupported(self):
+        # subclasses could run reposetup()s which affect supported.
+        return self._basesupported
+
     def join(self, f, *insidef):
         return self.vfs.join(os.path.join(f, *insidef))
@@ -279,8 +291,4 @@  class baselocalrepository(object):
 class localrepository(baselocalrepository):
 
-    supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest',
-                            'manifestv2'))
-    _basesupported = supportedformats | set(('store', 'fncache', 'shared',
-                                             'dotencode'))
     openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2'))
     filtername = None
@@ -300,20 +308,4 @@  class localrepository(baselocalrepositor
                                                 realfs=False)
 
-        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:
-                if setupfunc.__module__ in extmods:
-                    setupfunc(self.ui, self.supported)
-        else:
-            self.supported = self._basesupported
-
-        # Add compression engines.
-        for name in util.compengines:
-            engine = util.compengines[name]
-            if engine.revlogheader():
-                self.supported.add('exp-compression-%s' % name)
-
         if not self.vfs.isdir():
             if create:
@@ -400,4 +392,21 @@  class localrepository(baselocalrepositor
         extensions.loadall(self.ui)
 
+    def _loadsupported(self):
+        supported = set(self._basesupported) # use private copy
+        if self.featuresetupfuncs:
+            extmods = set(m.__name__ for n, m
+                          in extensions.extensions(self.ui))
+            for setupfunc in self.featuresetupfuncs:
+                if setupfunc.__module__ in extmods:
+                    setupfunc(self.ui, supported)
+
+        # Add compression engines.
+        for name in util.compengines:
+            engine = util.compengines[name]
+            if engine.revlogheader():
+                supported.add('exp-compression-%s' % name)
+
+        return supported
+
     def _writecaches(self):
         if self._revbranchcache: