Patchwork [3,of,5] manifestv2: set requires at repo creation time

login
register
mail settings
Submitter Martin von Zweigbergk
Date April 1, 2015, 5:34 p.m.
Message ID <7530c75651b04d04e087.1427909688@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8420/
State Accepted
Headers show

Comments

Martin von Zweigbergk - April 1, 2015, 5:34 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1427867145 25200
#      Tue Mar 31 22:45:45 2015 -0700
# Node ID 7530c75651b04d04e0871c84dfda487b4e9e96b4
# Parent  f59f288c517d9a027d6f3fe4a313240d82f67fd8
manifestv2: set requires at repo creation time

While it should be safe to switch to the new manifest format on an
existing repo, let's keep it simple for now and make the configuration
have any effect only at repo creation time. If the configuration is
enabled then (at repo creation), we add an entry to requires and read
that instead of the configuration from then on.

Patch

diff -r f59f288c517d -r 7530c75651b0 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Mar 31 15:06:55 2015 -0700
+++ b/mercurial/localrepo.py	Tue Mar 31 22:45:45 2015 -0700
@@ -174,10 +174,10 @@ 
 
 class localrepository(object):
 
-    supportedformats = set(('revlogv1', 'generaldelta'))
+    supportedformats = set(('revlogv1', 'generaldelta', 'manifestv2'))
     _basesupported = supportedformats | set(('store', 'fncache', 'shared',
                                              'dotencode'))
-    openerreqs = set(('revlogv1', 'generaldelta'))
+    openerreqs = set(('revlogv1', 'generaldelta', 'manifestv2'))
     requirements = ['revlogv1']
     filtername = None
 
@@ -241,6 +241,8 @@ 
                     )
                 if self.ui.configbool('format', 'generaldelta', False):
                     requirements.append("generaldelta")
+                if self.ui.configbool('experimental', 'manifestv2', False):
+                    requirements.append("manifestv2")
                 requirements = set(requirements)
             else:
                 raise error.RepoError(_("repository %s not found") % path)
@@ -334,9 +336,6 @@ 
         usetreemanifest = self.ui.configbool('experimental', 'treemanifest')
         if usetreemanifest is not None:
             self.svfs.options['usetreemanifest'] = usetreemanifest
-        usemanifestv2 = self.ui.configbool('experimental', 'manifestv2')
-        if usemanifestv2 is not None:
-            self.svfs.options['usemanifestv2'] = usemanifestv2
 
     def _writerequirements(self):
         reqfile = self.vfs("requires", "w")
diff -r f59f288c517d -r 7530c75651b0 mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Mar 31 15:06:55 2015 -0700
+++ b/mercurial/manifest.py	Tue Mar 31 22:45:45 2015 -0700
@@ -605,7 +605,7 @@ 
         if opts is not None:
             cachesize = opts.get('manifestcachesize', cachesize)
             usetreemanifest = opts.get('usetreemanifest', usetreemanifest)
-            usemanifestv2 = opts.get('usemanifestv2', usemanifestv2)
+            usemanifestv2 = opts.get('manifestv2', usemanifestv2)
         self._mancache = util.lrucachedict(cachesize)
         revlog.revlog.__init__(self, opener, "00manifest.i")
         self._usetreemanifest = usetreemanifest
diff -r f59f288c517d -r 7530c75651b0 tests/test-manifestv2.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-manifestv2.t	Tue Mar 31 22:45:45 2015 -0700
@@ -0,0 +1,31 @@ 
+Check that entry is added to .hg/requires
+
+  $ hg --config experimental.manifestv2=True init repo
+  $ cd repo
+  $ grep manifestv2 .hg/requires
+  manifestv2
+
+Set up simple repo
+
+  $ echo a > file1
+  $ echo b > file2
+  $ echo c > file3
+  $ hg ci -Aqm 'initial'
+  $ echo d > file2
+  $ hg ci -m 'modify file2'
+
+Check that 'hg verify', which uses manifest.readdelta(), works
+
+  $ hg verify
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  3 files, 2 changesets, 4 total revisions
+
+TODO: Check that manifest revlog is smaller than for v1
+
+  $ hg debugindex -m
+     rev    offset  length   base linkrev nodeid       p1           p2
+       0         0     106      0       0 f6279f9f8b31 000000000000 000000000000
+       1       106      59      0       1 cd20459b75e6 f6279f9f8b31 000000000000