manifestv2: set requires at repo creation time
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 31 Mar 2015 22:45:45 -0700
changeset 24571 919f8ce040be
parent 24570 487245cbf1ab
child 24572 b83679eb5f86
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.
mercurial/localrepo.py
mercurial/manifest.py
tests/test-manifestv2.t
--- 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")
--- 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
--- /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