upgrade: add support for experimental safe share mode
Recently we introduce the share-safe functionality which makes shares share
requirements and config of share source. This patch adds support to
`debugupgraderepo` command to upgrade repository to share-safe mode when
`format.exp-share-safe` config is enabled.
Differential Revision: https://phab.mercurial-scm.org/D9144
--- a/mercurial/upgrade.py Mon Nov 30 14:11:03 2020 +0530
+++ b/mercurial/upgrade.py Thu Jun 25 13:13:21 2020 +0530
@@ -137,6 +137,7 @@
requirements.SIDEDATA_REQUIREMENT,
requirements.COPIESSDC_REQUIREMENT,
requirements.NODEMAP_REQUIREMENT,
+ requirements.SHARESAFE_REQUIREMENT,
}
for name in compression.compengines:
engine = compression.compengines[name]
@@ -337,6 +338,26 @@
@registerformatvariant
+class sharedsafe(requirementformatvariant):
+ name = b'exp-sharesafe'
+ _requirement = requirements.SHARESAFE_REQUIREMENT
+
+ default = False
+
+ description = _(
+ b'old shared repositories do not share source repository '
+ b'requirements and config. This leads to various problems '
+ b'when the source repository format is upgraded or some new '
+ b'extensions are enabled.'
+ )
+
+ upgrademessage = _(
+ b'Upgrades a repository to share-safe format so that future '
+ b'shares of this repository share its requirements and configs.'
+ )
+
+
+@registerformatvariant
class sparserevlog(requirementformatvariant):
name = b'sparserevlog'
@@ -1439,3 +1460,13 @@
b'repository is verified\n'
)
)
+
+ if sharedsafe.name in addedreqs:
+ ui.warn(
+ _(
+ b'repository upgraded to share safe mode, existing'
+ b' shares will still work in old non-safe mode. '
+ b'Re-share existing shares to use them in safe mode'
+ b' New shares will be created in safe mode.\n'
+ )
+ )
--- a/tests/test-copies-chain-merge.t Mon Nov 30 14:11:03 2020 +0530
+++ b/tests/test-copies-chain-merge.t Thu Jun 25 13:13:21 2020 +0530
@@ -649,6 +649,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no yes no
persistent-nodemap: no no no
--- a/tests/test-copies-in-changeset.t Mon Nov 30 14:11:03 2020 +0530
+++ b/tests/test-copies-in-changeset.t Thu Jun 25 13:13:21 2020 +0530
@@ -37,6 +37,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes yes no
persistent-nodemap: no no no
@@ -50,6 +51,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -417,6 +419,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes yes no
persistent-nodemap: no no no
@@ -442,6 +445,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes yes no
persistent-nodemap: no no no
@@ -469,6 +473,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes yes no
persistent-nodemap: no no no
--- a/tests/test-persistent-nodemap.t Mon Nov 30 14:11:03 2020 +0530
+++ b/tests/test-persistent-nodemap.t Thu Jun 25 13:13:21 2020 +0530
@@ -15,6 +15,7 @@
fncache: yes
dotencode: yes
generaldelta: yes
+ exp-sharesafe: no
sparserevlog: yes
sidedata: no
persistent-nodemap: yes
@@ -476,6 +477,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: yes no no
@@ -506,6 +508,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no yes no
--- a/tests/test-share-safe.t Mon Nov 30 14:11:03 2020 +0530
+++ b/tests/test-share-safe.t Thu Jun 25 13:13:21 2020 +0530
@@ -292,3 +292,89 @@
[255]
$ hg showconfig ui.curses -R ../shared1
false
+
+ $ cd ../
+
+Test that upgrading using debugupgraderepo works
+=================================================
+
+ $ hg init non-share-safe --config format.exp-share-safe=false
+ $ cd non-share-safe
+ $ hg debugrequirements
+ dotencode
+ fncache
+ generaldelta
+ revlogv1
+ sparserevlog
+ store
+ $ echo foo > foo
+ $ hg ci -Aqm 'added foo'
+ $ echo bar > bar
+ $ hg ci -Aqm 'added bar'
+
+Create a share before upgrading
+
+ $ cd ..
+ $ hg share non-share-safe nss-share
+ updating working directory
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg debugrequirements -R nss-share
+ dotencode
+ fncache
+ generaldelta
+ revlogv1
+ shared
+ sparserevlog
+ store
+ $ cd non-share-safe
+
+Upgrade
+
+ $ hg debugupgraderepo -q
+ requirements
+ preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+ added: exp-sharesafe
+
+ $ hg debugupgraderepo --run -q
+ upgrade will perform the following actions:
+
+ requirements
+ preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+ added: exp-sharesafe
+
+ repository upgraded to share safe mode, existing shares will still work in old non-safe mode. Re-share existing shares to use them in safe mode New shares will be created in safe mode.
+
+ $ hg debugrequirements
+ dotencode
+ exp-sharesafe
+ fncache
+ generaldelta
+ revlogv1
+ sparserevlog
+ store
+
+ $ cat .hg/requires
+ exp-sharesafe
+
+ $ cat .hg/store/requires
+ dotencode
+ fncache
+ generaldelta
+ revlogv1
+ sparserevlog
+ store
+
+ $ hg log -GT "{node}: {desc}\n"
+ @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+ |
+ o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+
+
+Make sure existing shares still works
+
+ $ hg log -GT "{node}: {desc}\n" -R ../nss-share
+ @ f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+ |
+ o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+
+ $ hg unshare -R ../nss-share
--- a/tests/test-sidedata.t Mon Nov 30 14:11:03 2020 +0530
+++ b/tests/test-sidedata.t Thu Jun 25 13:13:21 2020 +0530
@@ -54,6 +54,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -66,6 +67,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no yes no
persistent-nodemap: no no no
@@ -84,6 +86,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes no no
persistent-nodemap: no no no
@@ -96,6 +99,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes no no
persistent-nodemap: no no no
--- a/tests/test-upgrade-repo.t Mon Nov 30 14:11:03 2020 +0530
+++ b/tests/test-upgrade-repo.t Thu Jun 25 13:13:21 2020 +0530
@@ -56,6 +56,7 @@
fncache: yes
dotencode: yes
generaldelta: yes
+ exp-sharesafe: no
sparserevlog: yes
sidedata: no
persistent-nodemap: no
@@ -68,6 +69,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -80,6 +82,7 @@
fncache: yes no yes
dotencode: yes no yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -92,6 +95,7 @@
[formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
[formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
[formatvariant.name.uptodate|generaldelta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
+ [formatvariant.name.uptodate|exp-sharesafe: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
[formatvariant.name.uptodate|sparserevlog: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
[formatvariant.name.uptodate|sidedata: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
@@ -120,6 +124,12 @@
"repo": true
},
{
+ "config": false,
+ "default": false,
+ "name": "exp-sharesafe",
+ "repo": false
+ },
+ {
"config": true,
"default": true,
"name": "sparserevlog",
@@ -266,6 +276,7 @@
fncache: no
dotencode: no
generaldelta: no
+ exp-sharesafe: no
sparserevlog: no
sidedata: no
persistent-nodemap: no
@@ -278,6 +289,7 @@
fncache: no yes yes
dotencode: no yes yes
generaldelta: no yes yes
+ exp-sharesafe: no no no
sparserevlog: no yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -290,6 +302,7 @@
fncache: no yes yes
dotencode: no yes yes
generaldelta: no no yes
+ exp-sharesafe: no no no
sparserevlog: no no yes
sidedata: no no no
persistent-nodemap: no no no
@@ -302,6 +315,7 @@
[formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
[formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
[formatvariant.name.mismatchdefault|generaldelta: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
+ [formatvariant.name.uptodate|exp-sharesafe: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
[formatvariant.name.mismatchdefault|sparserevlog: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
[formatvariant.name.uptodate|sidedata: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
[formatvariant.name.uptodate|persistent-nodemap:][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
@@ -1289,6 +1303,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -1319,6 +1334,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -1352,6 +1368,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -1389,6 +1406,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes no no
persistent-nodemap: no no no
@@ -1426,6 +1444,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: no no no
persistent-nodemap: no no no
@@ -1463,6 +1482,7 @@
fncache: yes yes yes
dotencode: yes yes yes
generaldelta: yes yes yes
+ exp-sharesafe: no no no
sparserevlog: yes yes yes
sidedata: yes yes no
persistent-nodemap: no no no