[PATCH 2 of 4] treemanifests: prevent creating non-fncache repos

Martin von Zweigbergk martinvonz at google.com
Wed Feb 3 01:01:55 EST 2016


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1454474807 28800
#      Tue Feb 02 20:46:47 2016 -0800
# Node ID 40dcae5ac5a8fd677d61413f419bfd131e1f89c6
# Parent  de3954c992eda0c34742124dc96f589dbf50787e
treemanifests: prevent creating non-fncache repos

In order to make local and streaming (--uncompressed) clones work with
treemanifests, we will have to update the store (store.py). To save us
from needing support for treemanifests even in the ancient bundles,
let's prevent creation av repos with 'treemanifest' requirement and
not 'fncache' requirement set. The 'treemanifest' requirement can be
turned on in two ways:

 1. If config option 'experimental.treemanifest' is on at repo
   creation time.

 2. When pulling in a changegroup part with a 'treemanifest' parameter
    set.

For 1), we simply add the 'fncache' requirement as well, ignoring
"--config format.usefncache=False" from the user. For 2), the repo
already exists, so it's too late to turn 'fncache' on. Instead, we
report an error to the user.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1288,6 +1288,11 @@
         nbchangesets = int(inpart.params.get('nbchanges'))
     if ('treemanifest' in inpart.params and
         'treemanifest' not in op.repo.requirements):
+        if 'fncache' not in op.repo.requirements:
+            raise error.Abort(_("bundle contains tree manifests, but local "
+                                "repo uses old format"),
+                              hint="Please try again in recent clone.")
+
         if len(op.repo.changelog) != 0:
             raise error.Abort(_(
                 "bundle contains tree manifests, but local repo is "
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -303,6 +303,8 @@
                     self.requirements.add("generaldelta")
                 if self.ui.configbool('experimental', 'treemanifest', False):
                     self.requirements.add("treemanifest")
+                    # treemanifests require fncachestore, so force it on
+                    self.requirements.add("fncache")
                 if self.ui.configbool('experimental', 'manifestv2', False):
                     self.requirements.add("manifestv2")
             else:
diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -518,3 +518,24 @@
   checking files
   8 files, 3 changesets, 10 total revisions
   $ cd ..
+
+Repo format is forced to fncache
+
+  $ hg init --config format.usefncache=False \
+  >   --config experimental.treemanifest=True repo-format
+  $ grep -e treemanifest -e fncache repo-format/.hg/requires
+  fncache
+  treemanifest
+
+Can not pull into a pre-fncache repo
+
+  $ hg init --config format.usefncache=False repo-ancient
+  $ hg -R repo-ancient --config experimental.changegroup3=1 pull \
+  >   http://localhost:$HGPORT2
+  pulling from http://localhost:$HGPORT2/
+  requesting all changes
+  abort: bundle contains tree manifests, but local repo uses old format
+  (Please try again in recent clone.)
+  [255]
+  $ grep treemanifest repo-ancient/.hg/requires
+  [1]


More information about the Mercurial-devel mailing list