diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -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): 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 @@ -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