changeset 43135:6e3dc1eff5c7

upgrade: allow for `sidedata` removal If the side-date feature is removed, we need to drop them. Differential Revision: https://phab.mercurial-scm.org/D6943
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Oct 2019 23:36:51 -0400
parents 75ad8af9c95e
children ba5b062a1388
files mercurial/upgrade.py tests/test-sidedata.t tests/test-upgrade-repo.t
diffstat 3 files changed, 66 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/upgrade.py	Sun Oct 06 23:36:51 2019 -0400
+++ b/mercurial/upgrade.py	Sun Oct 06 23:36:51 2019 -0400
@@ -76,6 +76,7 @@
     """
     supported = {
         localrepo.SPARSEREVLOG_REQUIREMENT,
+        localrepo.SIDEDATA_REQUIREMENT,
     }
     for name in compression.compengines:
         engine = compression.compengines[name]
@@ -679,8 +680,18 @@
 )
 
 
-def getsidedatacompanion(srcrepo, destrepo):
-    return None
+def getsidedatacompanion(srcrepo, dstrepo):
+    sidedatacompanion = None
+    removedreqs = srcrepo.requirements - dstrepo.requirements
+    if localrepo.SIDEDATA_REQUIREMENT in removedreqs:
+
+        def sidedatacompanion(rl, rev):
+            rl = getattr(rl, '_revlog', rl)
+            if rl.flags(rev) & revlog.REVIDX_SIDEDATA:
+                return True, (), {}
+            return False, (), {}
+
+    return sidedatacompanion
 
 
 def matchrevlog(revlogfilter, entry):
--- a/tests/test-sidedata.t	Sun Oct 06 23:36:51 2019 -0400
+++ b/tests/test-sidedata.t	Sun Oct 06 23:36:51 2019 -0400
@@ -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 downgrade from 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
--- a/tests/test-upgrade-repo.t	Sun Oct 06 23:36:51 2019 -0400
+++ b/tests/test-upgrade-repo.t	Sun Oct 06 23:36:51 2019 -0400
@@ -1361,3 +1361,53 @@
    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