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 + removedreqs = srcrepo.requirements - dstrepo.requirements + if localrepo.SIDEDATA_REQUIREMENT in removedreqs: + 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 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/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