D6943: upgrade: allow for `sidedata` removal

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Tue Oct 1 12:08:37 EDT 2019


marmoute created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If the side-date feature is removed, we need to drop them.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6943

AFFECTED FILES
  mercurial/upgrade.py
  tests/test-sidedata.t
  tests/test-upgrade-repo.t
  tests/testlib/ext-sidedata.py

CHANGE DETAILS

diff --git a/tests/testlib/ext-sidedata.py b/tests/testlib/ext-sidedata.py
--- a/tests/testlib/ext-sidedata.py
+++ b/tests/testlib/ext-sidedata.py
@@ -50,9 +50,10 @@
     return text
 
 def wrapgetsidedatacompanion(orig, srcrepo, dstrepo):
-    assert orig(srcrepo, dstrepo) is None # deal with composition later
+    getsidedatacompanion = orig(srcrepo, dstrepo)
     if (not localrepo.SIDEDATA_REQUIREMENT in srcrepo.requirements
         and localrepo.SIDEDATA_REQUIREMENT in dstrepo.requirements):
+        assert getsidedatacompanion is None # deal with composition later
         def getsidedatacompanion(revlog, rev):
             update = {}
             revlog.sidedatanocheck = True
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -1356,7 +1356,54 @@
   sparserevlog
   store
   $ hg debugsidedata -c 0
-  2 sidedata entries
-   entry-0001 size 4
-   entry-0002 size 32
+
+downgrade
+
+  $ hg debugupgraderepo --config format.use-side-data=no --run --no-backup > /dev/null
+  $ hg debugformat -v
+  format-variant    repo config default
+  fncache:           yes    yes     yes
+  dotencode:         yes    yes     yes
+  generaldelta:      yes    yes     yes
+  sparserevlog:      yes    yes     yes
+  sidedata:           no     no      no
+  plain-cl-delta:    yes    yes     yes
+  compression:       zstd   zstd    zlib
+  compression-level: default default default
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  revlog-compression-zstd
+  revlogv1
+  sparserevlog
+  store
+  $ hg debugsidedata -c 0
+
+upgrade from hgrc
 
+  $ cat >> .hg/hgrc << EOF
+  > [format]
+  > use-side-data=yes
+  > EOF
+  $ hg debugupgraderepo --run --no-backup > /dev/null
+  $ hg debugformat -v
+  format-variant    repo config default
+  fncache:           yes    yes     yes
+  dotencode:         yes    yes     yes
+  generaldelta:      yes    yes     yes
+  sparserevlog:      yes    yes     yes
+  sidedata:          yes    yes      no
+  plain-cl-delta:    yes    yes     yes
+  compression:       zstd   zstd    zlib
+  compression-level: default default default
+  $ cat .hg/requires
+  dotencode
+  exp-sidedata-flag
+  fncache
+  generaldelta
+  revlog-compression-zstd
+  revlogv1
+  sparserevlog
+  store
+  $ hg debugsidedata -c 0
diff --git a/tests/test-sidedata.t b/tests/test-sidedata.t
--- a/tests/test-sidedata.t
+++ b/tests/test-sidedata.t
@@ -71,8 +71,8 @@
   compression-level: default default default
   $ hg debugupgraderepo -R up-no-side-data --config format.use-side-data=yes > /dev/null
 
-Check that we cannot upgrade to sidedata
-----------------------------------------
+Check that we can upgrade to sidedata
+-------------------------------------
 
   $ hg init up-side-data --config format.use-side-data=yes
   $ hg debugformat -v -R up-side-data
@@ -95,6 +95,4 @@
   plain-cl-delta:    yes    yes     yes
   compression:       zlib   zlib    zlib
   compression-level: default default default
-  $ hg debugupgraderepo -R up-side-data --config format.use-side-data=no
-  abort: cannot upgrade repository; requirement would be removed: exp-sidedata-flag
-  [255]
+  $ hg debugupgraderepo -R up-side-data --config format.use-side-data=no > /dev/null
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -74,6 +74,7 @@
     """
     supported = {
         localrepo.SPARSEREVLOG_REQUIREMENT,
+        localrepo.SIDEDATA_REQUIREMENT,
     }
     for name in compression.compengines:
         engine = compression.compengines[name]
@@ -595,8 +596,16 @@
                                  UPGRADE_MANIFEST,
                                  UPGRADE_FILELOG])
 
-def getsidedatacompanion(srcrepo, destrepo):
-    return None
+def getsidedatacompanion(srcrepo, dstrepo):
+    sidedatacompanion = None
+    if (localrepo.SIDEDATA_REQUIREMENT in srcrepo.requirements
+        and not localrepo.SIDEDATA_REQUIREMENT in dstrepo.requirements):
+        def sidedatacompanion(revlog, rev):
+            rl = getattr(revlog, '_revlog', revlog)
+            if rl.flags(rev) & revlog.REVIDX_SIDEDATA:
+                return True, (), {}
+            return False, (), {}
+    return sidedatacompanion
 
 def matchrevlog(revlogfilter, entry):
     """check is a revlog is selected for cloning
@@ -687,6 +696,9 @@
     # Do the actual copying.
     # FUTURE this operation can be farmed off to worker processes.
     seen = set()
+
+    sidedatacompanion = None
+
     for unencoded, encoded, size in alldatafiles:
         if unencoded.endswith('.d'):
             continue



To: marmoute, #hg-reviewers
Cc: mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list