# HG changeset patch # User Raphaël Gomès # Date 2021-03-03 11:30:23 # Node ID f4c325bf80fc4c7cd12d65f0489ea8f80e9db54c # Parent ee91966aec0ff3c957d3a4d86b66abf3d306a68c requirements: also add a generaldelta constant Continue the cleanup to the remaining requirements Differential Revision: https://phab.mercurial-scm.org/D10106 diff --git a/mercurial/bundlecaches.py b/mercurial/bundlecaches.py --- a/mercurial/bundlecaches.py +++ b/mercurial/bundlecaches.py @@ -9,6 +9,7 @@ from .thirdparty import attr from . import ( error, + requirements as requirementsmod, sslutil, util, ) @@ -164,7 +165,7 @@ def parsebundlespec(repo, spec, strict=T compression = spec version = b'v1' # Generaldelta repos require v2. - if b'generaldelta' in repo.requirements: + if requirementsmod.GENERALDELTA_REQUIREMENT in repo.requirements: version = b'v2' # Modern compression engines require v2. if compression not in _bundlespecv1compengines: diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -1549,7 +1549,7 @@ def safeversion(repo): # will support. For example, all hg versions that support generaldelta also # support changegroup 02. versions = supportedoutgoingversions(repo) - if b'generaldelta' in repo.requirements: + if requirements.GENERALDELTA_REQUIREMENT in repo.requirements: versions.discard(b'01') assert versions return min(versions) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1003,7 +1003,7 @@ def resolverevlogstorevfsoptions(ui, req if requirementsmod.REVLOGV2_REQUIREMENT in requirements: options[b'revlogv2'] = True - if b'generaldelta' in requirements: + if requirementsmod.GENERALDELTA_REQUIREMENT in requirements: options[b'generaldelta'] = True # experimental config: format.chunkcachesize @@ -1200,7 +1200,7 @@ class localrepository(object): # chains), and the code was deleted in 4.6. supportedformats = { requirementsmod.REVLOGV1_REQUIREMENT, - b'generaldelta', + requirementsmod.GENERALDELTA_REQUIREMENT, requirementsmod.TREEMANIFEST_REQUIREMENT, requirementsmod.COPIESSDC_REQUIREMENT, requirementsmod.REVLOGV2_REQUIREMENT, @@ -3442,7 +3442,7 @@ def newreporequirements(ui, createopts): requirements.add(b'exp-compression-%s' % compengine) if scmutil.gdinitconfig(ui): - requirements.add(b'generaldelta') + requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT) if ui.configbool(b'format', b'sparse-revlog'): requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT) @@ -3460,7 +3460,7 @@ def newreporequirements(ui, createopts): if revlogv2 == b'enable-unstable-format-and-corrupt-my-data': requirements.remove(requirementsmod.REVLOGV1_REQUIREMENT) # generaldelta is implied by revlogv2. - requirements.discard(b'generaldelta') + requirements.discard(requirementsmod.GENERALDELTA_REQUIREMENT) requirements.add(requirementsmod.REVLOGV2_REQUIREMENT) # experimental config: format.internal-phase if ui.configbool(b'format', b'internal-phase'): diff --git a/mercurial/requirements.py b/mercurial/requirements.py --- a/mercurial/requirements.py +++ b/mercurial/requirements.py @@ -7,6 +7,8 @@ from __future__ import absolute_import +GENERALDELTA_REQUIREMENT = b'generaldelta' + # When narrowing is finalized and no longer subject to format changes, # we should move this to just "narrow" or similar. NARROW_REQUIREMENT = b'narrowhg-experimental' diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py --- a/mercurial/upgrade_utils/actions.py +++ b/mercurial/upgrade_utils/actions.py @@ -20,7 +20,7 @@ from ..utils import compression # list of requirements that request a clone of all revlog if added/removed RECLONES_REQUIREMENTS = { - b'generaldelta', + requirements.GENERALDELTA_REQUIREMENT, requirements.SPARSEREVLOG_REQUIREMENT, } @@ -236,7 +236,7 @@ class dotencode(requirementformatvariant class generaldelta(requirementformatvariant): name = b'generaldelta' - _requirement = b'generaldelta' + _requirement = requirements.GENERALDELTA_REQUIREMENT default = True @@ -936,7 +936,7 @@ def supporteddestrequirements(repo): supported = { b'dotencode', b'fncache', - b'generaldelta', + requirements.GENERALDELTA_REQUIREMENT, requirements.REVLOGV1_REQUIREMENT, b'store', requirements.SPARSEREVLOG_REQUIREMENT, @@ -967,7 +967,7 @@ def allowednewrequirements(repo): supported = { b'dotencode', b'fncache', - b'generaldelta', + requirements.GENERALDELTA_REQUIREMENT, requirements.SPARSEREVLOG_REQUIREMENT, requirements.SIDEDATA_REQUIREMENT, requirements.COPIESSDC_REQUIREMENT, diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py --- a/mercurial/wireprotov1server.py +++ b/mercurial/wireprotov1server.py @@ -109,7 +109,7 @@ def bundle1allowed(repo, action): 4. server.bundle1 """ ui = repo.ui - gd = b'generaldelta' in repo.requirements + gd = requirementsmod.GENERALDELTA_REQUIREMENT in repo.requirements if gd: v = ui.configbool(b'server', b'bundle1gd.%s' % action)