Patchwork [2,of,6,V3] treemanifest: add configuration for using treemanifest type

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 19, 2015, 7:52 p.m.
Message ID <b1b244db5243fb4246fd.1426794774@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8176/
State Accepted
Commit c2287f203ec4b4b25587fd4d21d81c52a53bebee
Headers show

Comments

Martin von Zweigbergk - March 19, 2015, 7:52 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1426788477 25200
#      Thu Mar 19 11:07:57 2015 -0700
# Node ID b1b244db5243fb4246fd86f0a61fc906130b27f8
# Parent  5b4a29d0093d1fce3230cf09cca111b2258380cb
treemanifest: add configuration for using treemanifest type

This change adds boolean configuration option
experimental.treemanifest. When the option is enabled, manifests are
parsed into the new treemanifest type.

Tests can be now run using treemanifest by switching the config option
default in localrepo._applyrequirements(). Tests pass even when made
to randomly choose between manifestdict and treemanifest, suggesting
that the two types produce identical manifests (so e.g. a manifest
revlog entry written from a treemanifest can be parsed by the
manifestdict code).

Patch

diff -r 5b4a29d0093d -r b1b244db5243 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/localrepo.py	Thu Mar 19 11:07:57 2015 -0700
@@ -331,6 +331,9 @@ 
         manifestcachesize = self.ui.configint('format', 'manifestcachesize')
         if manifestcachesize is not None:
             self.svfs.options['manifestcachesize'] = manifestcachesize
+        usetreemanifest = self.ui.configbool('experimental', 'treemanifest')
+        if usetreemanifest is not None:
+            self.svfs.options['usetreemanifest'] = usetreemanifest
 
     def _writerequirements(self):
         reqfile = self.vfs("requires", "w")
diff -r 5b4a29d0093d -r b1b244db5243 mercurial/manifest.py
--- a/mercurial/manifest.py	Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py	Thu Mar 19 11:07:57 2015 -0700
@@ -556,16 +556,24 @@ 
         # 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
         opts = getattr(opener, 'options', None)
         if opts is not None:
             cachesize = opts.get('manifestcachesize', cachesize)
+            usetreemanifest = opts.get('usetreemanifest', usetreemanifest)
         self._mancache = util.lrucachedict(cachesize)
         revlog.revlog.__init__(self, opener, "00manifest.i")
+        self._usetreemanifest = usetreemanifest
+
+    def _newmanifest(self, data=''):
+        if self._usetreemanifest:
+            return treemanifest(data)
+        return manifestdict(data)
 
     def readdelta(self, node):
         r = self.rev(node)
         d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r))
-        return manifestdict(d)
+        return self._newmanifest(d)
 
     def readfast(self, node):
         '''use the faster of readdelta or read'''
@@ -577,12 +585,12 @@ 
 
     def read(self, node):
         if node == revlog.nullid:
-            return manifestdict() # don't upset local cache
+            return self._newmanifest() # don't upset local cache
         if node in self._mancache:
             return self._mancache[node][0]
         text = self.revision(node)
         arraytext = array.array('c', text)
-        m = manifestdict(text)
+        m = self._newmanifest(text)
         self._mancache[node] = (m, arraytext)
         return m
 
@@ -596,7 +604,7 @@ 
             return None, None
 
     def add(self, m, transaction, link, p1, p2, added, removed):
-        if p1 in self._mancache:
+        if p1 in self._mancache and not self._usetreemanifest:
             # If our first parent is in the manifest cache, we can
             # compute a delta here using properties we know about the
             # manifest up-front, which may save time later for the