# HG changeset patch # User Pierre-Yves David # Date 1582129804 -3600 # Node ID f0027a3dd7cb6a0387b1880362ace0e468054e04 # Parent 454bc51f114c50dc70f4e794f694075579ad3c81 revlog-compression: update the config to be a list format.revlog-compression is now a list of engine, the first supported one is to be used. Doing this have several benefits: 1) this is fully backward compatible, config using a single entry will be read as a single item list, not changing any behavior. 2) This open the way to use zstd by default without impacting platform were it is not available. This will be done in a later changesets. Using zstd provide a significant performance boost explained in : bb271ec2fbfb. However zstd is not available in some cases, A notable example is the `--pure` version of Mercurial which doesn't come with zstd support. Differential Revision: https://phab.mercurial-scm.org/D8148 diff -r 454bc51f114c -r f0027a3dd7cb mercurial/configitems.py --- a/mercurial/configitems.py Wed Feb 19 13:39:00 2020 +0530 +++ b/mercurial/configitems.py Wed Feb 19 17:30:04 2020 +0100 @@ -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 -r 454bc51f114c -r f0027a3dd7cb mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt Wed Feb 19 13:39:00 2020 +0530 +++ b/mercurial/helptext/config.txt Wed Feb 19 17:30:04 2020 +0100 @@ -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 -r 454bc51f114c -r f0027a3dd7cb mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Feb 19 13:39:00 2020 +0530 +++ b/mercurial/localrepo.py Wed Feb 19 17:30:04 2020 +0100 @@ -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 -r 454bc51f114c -r f0027a3dd7cb mercurial/upgrade.py --- a/mercurial/upgrade.py Wed Feb 19 13:39:00 2020 +0530 +++ b/mercurial/upgrade.py Wed Feb 19 17:30:04 2020 +0100 @@ -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 -r 454bc51f114c -r f0027a3dd7cb tests/test-repo-compengines.t --- a/tests/test-repo-compengines.t Wed Feb 19 13:39:00 2020 +0530 +++ b/tests/test-repo-compengines.t Wed Feb 19 17:30:04 2020 +0100 @@ -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