diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -645,6 +645,8 @@ def gathersupportedrequirements(ui): 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 @@ def resolverevlogstorevfsoptions(ui, req 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 @@ def newreporequirements(ui, createopts): '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 --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -325,10 +325,16 @@ class compressionengine(formatvariant): @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 --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 @@ -44,9 +44,9 @@ A requirement specifying an unknown comp $ cd zstd $ cat .hg/requires dotencode - exp-compression-zstd fncache generaldelta + revlog-compression-zstd revlogv1 sparserevlog store