Skip to content
Snippets Groups Projects
Commit d086ba38 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

upgrade: support upgrade to/from zstd storage (issue6088)

Now that we have an official config option for a shiny format improvement, we
better make it simple to migrate to/from it.
parent 10a6725d
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,10 @@
vfs as vfsmod,
)
from .utils import (
compression,
)
def requiredsourcerequirements(repo):
"""Obtain requirements required to be present to upgrade a repo.
......@@ -61,6 +65,6 @@
the dropped requirement must appear in the returned set for the upgrade
to be allowed.
"""
return {
supported = {
localrepo.SPARSEREVLOG_REQUIREMENT,
}
......@@ -65,5 +69,12 @@
localrepo.SPARSEREVLOG_REQUIREMENT,
}
for name in compression.compengines:
engine = compression.compengines[name]
if engine.available() and engine.revlogheader():
supported.add(b'exp-compression-%s' % name)
if engine.name() == 'zstd':
supported.add(b'revlog-compression-zstd')
return supported
def supporteddestrequirements(repo):
"""Obtain requirements that upgrade supports in the destination.
......@@ -73,7 +84,7 @@
Extensions should monkeypatch this to add their custom requirements.
"""
return {
supported = {
'dotencode',
'fncache',
'generaldelta',
......@@ -81,6 +92,13 @@
'store',
localrepo.SPARSEREVLOG_REQUIREMENT,
}
for name in compression.compengines:
engine = compression.compengines[name]
if engine.available() and engine.revlogheader():
supported.add(b'exp-compression-%s' % name)
if engine.name() == 'zstd':
supported.add(b'revlog-compression-zstd')
return supported
def allowednewrequirements(repo):
"""Obtain requirements that can be added to a repository during upgrade.
......@@ -92,9 +110,9 @@
bad additions because the whitelist approach is safer and will prevent
future, unknown requirements from accidentally being added.
"""
return {
supported = {
'dotencode',
'fncache',
'generaldelta',
localrepo.SPARSEREVLOG_REQUIREMENT,
}
......@@ -96,8 +114,15 @@
'dotencode',
'fncache',
'generaldelta',
localrepo.SPARSEREVLOG_REQUIREMENT,
}
for name in compression.compengines:
engine = compression.compengines[name]
if engine.available() and engine.revlogheader():
supported.add(b'exp-compression-%s' % name)
if engine.name() == 'zstd':
supported.add(b'revlog-compression-zstd')
return supported
def preservedrequirements(repo):
return set()
......
......@@ -854,4 +854,76 @@
generaldelta
revlogv1
store
#if zstd
Check upgrading to a zstd revlog
--------------------------------
upgrade
$ hg --config format.revlog-compression=zstd 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
plain-cl-delta: yes yes yes
compression: zstd zlib zlib
compression-level: default default default
$ cat .hg/requires
dotencode
fncache
generaldelta
revlog-compression-zstd
revlogv1
sparserevlog
store
downgrade
$ 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
plain-cl-delta: yes yes yes
compression: zlib zlib zlib
compression-level: default default default
$ cat .hg/requires
dotencode
fncache
generaldelta
revlogv1
sparserevlog
store
upgrade from hgrc
$ cat >> .hg/hgrc << EOF
> [format]
> revlog-compression=zstd
> 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
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
$ cd ..
......@@ -857,1 +929,3 @@
$ cd ..
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment