Patchwork [V2] treemanifest: allow manifestrevlog to take an explicit treemanifest arg

login
register
mail settings
Submitter Durham Goode
Date May 9, 2017, 8:57 p.m.
Message ID <9eadb203ad96f3f66dc3.1494363438@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/20544/
State Accepted
Headers show

Comments

Durham Goode - May 9, 2017, 8:57 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1494363406 25200
#      Tue May 09 13:56:46 2017 -0700
# Node ID 9eadb203ad96f3f66dc39b765e6422e1df6b6986
# Parent  8f1a2b848b52ea7bf3fe2404e3b62924c7aae93f
treemanifest: allow manifestrevlog to take an explicit treemanifest arg

Previously we relied on the opener options to tell the revlog to be a tree
manifest. This makes it complicated for extensions to create treemanifests and
normal manifests at the same time. Let's add a construtor argument to create a
treemanifest revlog as well.

I considered removing the options['treemanifest'] logic from manifestrevlog
entirely, but doing so shifts the responsibility to the caller which ends up
requiring changes in localrepo, bundlerepo, and unionrepo. I figured having the
dual mechanism was better than polluting other parts of the code base with
treemanifest knowledge.
Augie Fackler - May 13, 2017, 2:16 a.m.
On Tue, May 09, 2017 at 01:57:18PM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1494363406 25200
> #      Tue May 09 13:56:46 2017 -0700
> # Node ID 9eadb203ad96f3f66dc39b765e6422e1df6b6986
> # Parent  8f1a2b848b52ea7bf3fe2404e3b62924c7aae93f
> treemanifest: allow manifestrevlog to take an explicit treemanifest arg

queued, thanks

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1175,25 +1175,31 @@  class manifestrevlog(revlog.revlog):
     '''A revlog that stores manifest texts. This is responsible for caching the
     full-text manifest contents.
     '''
-    def __init__(self, opener, dir='', dirlogcache=None, indexfile=None):
+    def __init__(self, opener, dir='', dirlogcache=None, indexfile=None,
+                 treemanifest=False):
         """Constructs a new manifest revlog
 
         `indexfile` - used by extensions to have two manifests at once, like
         when transitioning between flatmanifeset and treemanifests.
+
+        `treemanifest` - used to indicate this is a tree manifest revlog. Opener
+        options can also be used to make this a tree manifest revlog. The opener
+        option takes precedence, so if it is set to True, we ignore whatever
+        value is passed in to the constructor.
         """
         # 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
+        optiontreemanifest = False
         usemanifestv2 = False
         opts = getattr(opener, 'options', None)
         if opts is not None:
             cachesize = opts.get('manifestcachesize', cachesize)
-            usetreemanifest = opts.get('treemanifest', usetreemanifest)
+            optiontreemanifest = opts.get('treemanifest', False)
             usemanifestv2 = opts.get('manifestv2', usemanifestv2)
 
-        self._treeondisk = usetreemanifest
+        self._treeondisk = optiontreemanifest or treemanifest
         self._usemanifestv2 = usemanifestv2
 
         self._fulltextcache = util.lrucachedict(cachesize)
@@ -1231,8 +1237,10 @@  class manifestrevlog(revlog.revlog):
         if dir:
             assert self._treeondisk
         if dir not in self._dirlogcache:
-            self._dirlogcache[dir] = manifestrevlog(self.opener, dir,
-                                                    self._dirlogcache)
+            mfrevlog = manifestrevlog(self.opener, dir,
+                                      self._dirlogcache,
+                                      treemanifest=self._treeondisk)
+            self._dirlogcache[dir] = mfrevlog
         return self._dirlogcache[dir]
 
     def add(self, m, transaction, link, p1, p2, added, removed, readtree=None):