diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -759,7 +759,7 @@ coreconfigitem( b'format', b'revlog-compression', - default=b'zlib', + default=lambda: [b'zlib'], alias=[(b'experimental', b'format.compression')], ) coreconfigitem( diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -888,7 +888,8 @@ Compression algorithm used by revlog. Supported values are `zlib` and `zstd`. The `zlib` engine is the historical default of Mercurial. `zstd` is a newer format that is usually a net win over `zlib`, operating faster at - better compression rates. Use `zstd` to reduce CPU usage. + better compression rates. Use `zstd` to reduce CPU usage. Multiple values + can be specified, the first available one will be used. On some systems, the Mercurial installation may lack `zstd` support. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -3578,14 +3578,17 @@ if ui.configbool(b'format', b'dotencode'): requirements.add(b'dotencode') - compengine = ui.config(b'format', b'revlog-compression') - if compengine not in util.compengines: + compengines = ui.configlist(b'format', b'revlog-compression') + for compengine in compengines: + if compengine in util.compengines: + break + else: raise error.Abort( _( - b'compression engine %s defined by ' + b'compression engines %s defined by ' b'format.revlog-compression not available' ) - % compengine, + % b', '.join(b'"%s"' % e for e in compengines), hint=_( b'run "hg debuginstall" to list available ' b'compression engines' @@ -3593,7 +3596,7 @@ ) # zlib is the historical default and doesn't need an explicit requirement. - elif compengine == b'zstd': + if compengine == b'zstd': requirements.add(b'revlog-compression-zstd') elif compengine != b'zlib': requirements.add(b'exp-compression-%s' % compengine) diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -449,7 +449,14 @@ @classmethod def fromconfig(cls, repo): - return repo.ui.config(b'format', b'revlog-compression') + compengines = repo.ui.configlist(b'format', b'revlog-compression') + # return the first valid value as the selection code would do + for comp in compengines: + if comp in util.compengines: + return comp + + # no valide compression found lets display it all for clarity + return b','.join(compengines) @registerformatvariant diff --git a/tests/test-repo-compengines.t b/tests/test-repo-compengines.t --- a/tests/test-repo-compengines.t +++ b/tests/test-repo-compengines.t @@ -22,10 +22,15 @@ Unknown compression engine to format.compression aborts $ hg --config format.revlog-compression=unknown init unknown - abort: compression engine unknown defined by format.revlog-compression not available + abort: compression engines "unknown" defined by format.revlog-compression not available (run "hg debuginstall" to list available compression engines) [255] +unknown compression engine in a list with known one works fine + + $ hg --config format.revlog-compression=zlib,unknown init zlib-before-unknow + $ hg --config format.revlog-compression=unknown,zlib init unknown-before-zlib + A requirement specifying an unknown compression engine results in bail $ hg init unknownrequirement