# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2020-08-08 10:18:17 # Node ID e58e234096deeebea045f69c69ea4392f71ac1b8 # Parent 15d35f2ba4743325da0aa5aa3bc071c082f4b149 repository: introduce constant for treemanifest requirement and use it In future we will like to much cleaner logic around which requirement is for working copy and which can go in store. To start with that, we first need to de-clutter the requirement values spread around and replace them with constants. Differential Revision: https://phab.mercurial-scm.org/D8916 diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py --- a/hgext/narrow/narrowbundle2.py +++ b/hgext/narrow/narrowbundle2.py @@ -108,7 +108,7 @@ def generateellipsesbundle2( part = bundler.newpart(b'changegroup', data=cgdata) part.addparam(b'version', version) - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: part.addparam(b'treemanifest', b'1') @@ -163,7 +163,7 @@ def generate_ellipses_bundle2_for_wideni part = bundler.newpart(b'changegroup', data=cgdata) part.addparam(b'version', version) - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: part.addparam(b'treemanifest', b'1') diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -30,6 +30,7 @@ from mercurial import ( wireprototypes, wireprotov1server, ) +from mercurial.interfaces import repository from . import ( constants, shallowutil, @@ -169,7 +170,7 @@ def onetimesetup(ui): if kind == stat.S_IFDIR: visit.append(fp) - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: for (u, e, s) in repo.store.datafiles(): if u.startswith(b'meta/') and ( u.endswith(b'.i') or u.endswith(b'.d') diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -172,6 +172,7 @@ from . import ( url, util, ) +from .interfaces import repository from .utils import stringutil urlerr = util.urlerr @@ -1965,7 +1966,7 @@ def handlechangegroup(op, inpart): nbchangesets = int(inpart.params.get(b'nbchanges')) if ( b'treemanifest' in inpart.params - and b'treemanifest' not in op.repo.requirements + and repository.TREEMANIFEST_REQUIREMENT not in op.repo.requirements ): if len(op.repo.changelog) != 0: raise error.Abort( @@ -1974,7 +1975,7 @@ def handlechangegroup(op, inpart): b"non-empty and does not use tree manifests" ) ) - op.repo.requirements.add(b'treemanifest') + op.repo.requirements.add(repository.TREEMANIFEST_REQUIREMENT) op.repo.svfs.options = localrepo.resolvestorevfsoptions( op.repo.ui, op.repo.requirements, op.repo.features ) @@ -2576,7 +2577,7 @@ def widen_bundle( part = bundler.newpart(b'changegroup', data=cgdata) part.addparam(b'version', cgversion) - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: part.addparam(b'treemanifest', b'1') if b'exp-sidedata-flag' in repo.requirements: part.addparam(b'exp-sidedata', b'1') diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -949,7 +949,7 @@ class cgpacker(object): # either, because we don't discover which directory nodes to # send along with files. This could probably be fixed. fastpathlinkrev = fastpathlinkrev and ( - b'treemanifest' not in repo.requirements + repository.TREEMANIFEST_REQUIREMENT not in repo.requirements ) fnodes = {} # needed file nodes @@ -1467,7 +1467,7 @@ def allsupportedversions(repo): if ( repo.ui.configbool(b'experimental', b'changegroup3') or repo.ui.configbool(b'experimental', b'treemanifest') - or b'treemanifest' in repo.requirements + or repository.TREEMANIFEST_REQUIREMENT in repo.requirements ): # we keep version 03 because we need to to exchange treemanifest data # @@ -1495,7 +1495,7 @@ def supportedincomingversions(repo): # Changegroup versions that can be created from the repo def supportedoutgoingversions(repo): versions = allsupportedversions(repo) - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: # Versions 01 and 02 support only flat manifests and it's just too # expensive to convert between the flat manifest and tree manifest on # the fly. Since tree manifests are hashed differently, all of history diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -58,6 +58,8 @@ from . import ( vfs as vfsmod, ) +from .interfaces import repository + from .utils import ( dateutil, stringutil, @@ -1358,7 +1360,7 @@ def openstorage(repo, cmd, file_, opts, if cl: r = repo.unfiltered().changelog elif dir: - if b'treemanifest' not in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT not in repo.requirements: raise error.Abort( _( b"--dir can only be used on repos with " diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1068,7 +1068,7 @@ def _pushb2ctx(pushop, bundler): cgpart = bundler.newpart(b'changegroup', data=cgstream) if cgversions: cgpart.addparam(b'version', version) - if b'treemanifest' in pushop.repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in pushop.repo.requirements: cgpart.addparam(b'treemanifest', b'1') if b'exp-sidedata-flag' in pushop.repo.requirements: cgpart.addparam(b'exp-sidedata', b'1') @@ -2557,7 +2557,7 @@ def _getbundlechangegrouppart( part.addparam(b'nbchanges', b'%d' % len(outgoing.missing), mandatory=False) - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: part.addparam(b'treemanifest', b'1') if b'exp-sidedata-flag' in repo.requirements: diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -22,6 +22,9 @@ SPARSE_REQUIREMENT = b'exp-sparse' # of stripping them INTERNAL_PHASE_REQUIREMENT = b'internal-phase' +# Stores manifest in Tree structure +TREEMANIFEST_REQUIREMENT = b'treemanifest' + # Local repository feature string. # Revlogs are being used for file storage. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -846,7 +846,7 @@ def resolvestorevfsoptions(ui, requireme """ options = {} - if b'treemanifest' in requirements: + if repository.TREEMANIFEST_REQUIREMENT in requirements: options[b'treemanifest'] = True # experimental config: format.manifestcachesize @@ -1053,7 +1053,7 @@ class localrepository(object): supportedformats = { b'revlogv1', b'generaldelta', - b'treemanifest', + repository.TREEMANIFEST_REQUIREMENT, COPIESSDC_REQUIREMENT, REVLOGV2_REQUIREMENT, SIDEDATA_REQUIREMENT, @@ -3314,7 +3314,7 @@ def newreporequirements(ui, createopts): requirements.add(SIDEDATA_REQUIREMENT) requirements.add(COPIESSDC_REQUIREMENT) if ui.configbool(b'experimental', b'treemanifest'): - requirements.add(b'treemanifest') + requirements.add(repository.TREEMANIFEST_REQUIREMENT) revlogv2 = ui.config(b'experimental', b'revlogv2') if revlogv2 == b'enable-unstable-format-and-corrupt-my-data': diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -28,6 +28,7 @@ from . import ( pycompat, util, ) +from .interfaces import repository from .utils import ( hashutil, stringutil, @@ -418,7 +419,7 @@ def stripmanifest(repo, striprev, tr, fi def manifestrevlogs(repo): yield repo.manifestlog.getstorage(b'') - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: # This logic is safe if treemanifest isn't enabled, but also # pointless, so we skip it if treemanifest isn't enabled. for unencoded, encoded, size in repo.store.datafiles(): @@ -476,7 +477,7 @@ def rebuildfncache(ui, repo): progress.complete() - if b'treemanifest' in repo.requirements: + if repository.TREEMANIFEST_REQUIREMENT in repo.requirements: # This logic is safe if treemanifest isn't enabled, but also # pointless, so we skip it if treemanifest isn't enabled. for dir in pathutil.dirs(seenfiles): diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -26,6 +26,7 @@ from . import ( vfs as vfsmod, ) +from .interfaces import repository from .utils import compression # list of requirements that request a clone of all revlog if added/removed @@ -58,7 +59,7 @@ def blocksourcerequirements(repo): return { # The upgrade code does not yet support these experimental features. # This is an artificial limitation. - b'treemanifest', + repository.TREEMANIFEST_REQUIREMENT, # This was a precursor to generaldelta and was never enabled by default. # It should (hopefully) not exist in the wild. b'parentdelta',