[PATCH 3 of 4] manifest: move revlog specific options from manifest to manifestrevlog

Durham Goode durham at fb.com
Tue Sep 13 19:30:46 EDT 2016


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1473807641 25200
#      Tue Sep 13 16:00:41 2016 -0700
# Node ID 460e9339cd89add743326b16463f04737a0b4db0
# Parent  f5b0e6f84938d661ee32b2303cb17e30a3fbb9df
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.

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -896,18 +896,34 @@ class manifestrevlog(revlog.revlog):
     '''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 @@ class manifest(manifestrevlog):
         # 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


More information about the Mercurial-devel mailing list