# HG changeset patch # User Pierre-Yves David # Date 1553707623 -3600 # Node ID 10a6725dca6e344cb6f9e1b8cd30972ba4b3e4f7 # Parent b970fece153dd118593542f306adff386c08295a compression: introduce an official `zstd-revlog` requirement This requirement supersedes `exp-compression-zstd`. However, we keep support for the old requirement. Strictly speaking, we do not need to add a new requirement, there are no logic change making "new" repo incompatible with mercurial client using a version that support `exp-compression-zstd`. The choice to introduce a new requirement is motivated by the following: * The previous requirement was explicitly "experimental". Using it by default could confuse users. * adding support for a hypothetical third compression engine will requires new code, and will comes with its own requirement tool. * We won't use it as the default for a while since I do not think we support zstd on all platform. I can imagine we'll gain another (unrelated but on my default) requirement by the time we turn this zstd by default. diff -r b970fece153d -r 10a6725dca6e mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Apr 16 15:10:16 2019 +0200 +++ b/mercurial/localrepo.py Wed Mar 27 18:27:03 2019 +0100 @@ -645,6 +645,8 @@ engine = util.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 @@ -794,8 +796,13 @@ options[b'maxchainlen'] = maxchainlen for r in requirements: - if r.startswith(b'exp-compression-'): - options[b'compengine'] = r[len(b'exp-compression-'):] + # we allow multiple compression engine requirement to co-exist because + # strickly speaking, revlog seems to support mixed compression style. + # + # The compression used for new entries will be "the last one" + prefix = r.startswith + if prefix('revlog-compression-') or prefix('exp-compression-'): + options[b'compengine'] = r.split('-', 2)[2] options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level') if options[b'zlib.level'] is not None: @@ -2943,7 +2950,9 @@ 'compression engines')) # zlib is the historical default and doesn't need an explicit requirement. - if compengine != 'zlib': + elif compengine == 'zstd': + requirements.add('revlog-compression-zstd') + elif compengine != 'zlib': requirements.add('exp-compression-%s' % compengine) if scmutil.gdinitconfig(ui): diff -r b970fece153d -r 10a6725dca6e mercurial/upgrade.py --- a/mercurial/upgrade.py Tue Apr 16 15:10:16 2019 +0200 +++ b/mercurial/upgrade.py Wed Mar 27 18:27:03 2019 +0100 @@ -325,10 +325,16 @@ @classmethod def fromrepo(cls, repo): + # we allow multiple compression engine requirement to co-exist because + # strickly speaking, revlog seems to support mixed compression style. + # + # The compression used for new entries will be "the last one" + compression = 'zlib' for req in repo.requirements: - if req.startswith('exp-compression-'): - return req.split('-', 2)[2] - return 'zlib' + prefix = req.startswith + if prefix('revlog-compression-') or prefix('exp-compression-'): + compression = req.split('-', 2)[2] + return compression @classmethod def fromconfig(cls, repo): diff -r b970fece153d -r 10a6725dca6e tests/test-repo-compengines.t --- a/tests/test-repo-compengines.t Tue Apr 16 15:10:16 2019 +0200 +++ b/tests/test-repo-compengines.t Wed Mar 27 18:27:03 2019 +0100 @@ -44,9 +44,9 @@ $ cd zstd $ cat .hg/requires dotencode - exp-compression-zstd fncache generaldelta + revlog-compression-zstd revlogv1 sparserevlog store