manifest: move revlog specific options from manifest to manifestrevlog
authorDurham Goode <durham@fb.com>
Tue, 13 Sep 2016 16:00:41 -0700
changeset 29944 fa145a205a7f
parent 29943 80be4436e4cc
child 29945 1cc93a154723
manifest: move revlog specific options from manifest to manifestrevlog The manifestv2 and treeondisk options are specific to how we serialize the manifest into revlogs, so let's move them onto the manifestrevlog class. This will allow us to add a manifestlog.add() function in a future diff that will rely on manifestrevlog to make decisions about how to serialize the given manifest to disk. We have to move a little bit of extra logic about the 'dir' as well, since it is used in conjunction with the treeondisk option to decide the revlog file name. It's probably good to move this down to the manifestrevlog class anyway, since it's specific to the revlog.
mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Sep 13 16:26:30 2016 -0700
+++ b/mercurial/manifest.py	Tue Sep 13 16:00:41 2016 -0700
@@ -896,18 +896,34 @@
     '''A revlog that stores manifest texts. This is responsible for caching the
     full-text manifest contents.
     '''
-    def __init__(self, opener, indexfile):
-        super(manifestrevlog, self).__init__(opener, indexfile)
-
+    def __init__(self, opener, dir=''):
         # During normal operations, we expect to deal with not more than four
         # revs at a time (such as during commit --amend). When rebasing large
         # stacks of commits, the number can go up, hence the config knob below.
         cachesize = 4
+        usetreemanifest = False
+        usemanifestv2 = False
         opts = getattr(opener, 'options', None)
         if opts is not None:
             cachesize = opts.get('manifestcachesize', cachesize)
+            usetreemanifest = opts.get('treemanifest', usetreemanifest)
+            usemanifestv2 = opts.get('manifestv2', usemanifestv2)
+
+        self._treeondisk = usetreemanifest
+        self._usemanifestv2 = usemanifestv2
+
         self._fulltextcache = util.lrucachedict(cachesize)
 
+        indexfile = "00manifest.i"
+        if dir:
+            assert self._treeondisk, 'opts is %r' % opts
+            if not dir.endswith('/'):
+                dir = dir + '/'
+            indexfile = "meta/" + dir + "00manifest.i"
+        self._dir = dir
+
+        super(manifestrevlog, self).__init__(opener, indexfile)
+
     @property
     def fulltextcache(self):
         return self._fulltextcache
@@ -1093,24 +1109,13 @@
         # stacks of commits, the number can go up, hence the config knob below.
         cachesize = 4
         usetreemanifest = False
-        usemanifestv2 = False
         opts = getattr(opener, 'options', None)
         if opts is not None:
             cachesize = opts.get('manifestcachesize', cachesize)
             usetreemanifest = opts.get('treemanifest', usetreemanifest)
-            usemanifestv2 = opts.get('manifestv2', usemanifestv2)
         self._mancache = util.lrucachedict(cachesize)
         self._treeinmem = usetreemanifest
-        self._treeondisk = usetreemanifest
-        self._usemanifestv2 = usemanifestv2
-        indexfile = "00manifest.i"
-        if dir:
-            assert self._treeondisk, 'opts is %r' % opts
-            if not dir.endswith('/'):
-                dir = dir + '/'
-            indexfile = "meta/" + dir + "00manifest.i"
-        super(manifest, self).__init__(opener, indexfile)
-        self._dir = dir
+        super(manifest, self).__init__(opener, dir=dir)
         # The dirlogcache is kept on the root manifest log
         if dir:
             self._dirlogcache = dirlogcache