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
--- a/hgext/narrow/narrowbundle2.py Tue Jul 21 22:13:54 2020 +0200
+++ b/hgext/narrow/narrowbundle2.py Sat Aug 08 15:48:17 2020 +0530
@@ -108,7 +108,7 @@
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 @@
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')
--- a/hgext/remotefilelog/remotefilelogserver.py Tue Jul 21 22:13:54 2020 +0200
+++ b/hgext/remotefilelog/remotefilelogserver.py Sat Aug 08 15:48:17 2020 +0530
@@ -30,6 +30,7 @@
wireprototypes,
wireprotov1server,
)
+from mercurial.interfaces import repository
from . import (
constants,
shallowutil,
@@ -169,7 +170,7 @@
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')
--- a/mercurial/bundle2.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/bundle2.py Sat Aug 08 15:48:17 2020 +0530
@@ -172,6 +172,7 @@
url,
util,
)
+from .interfaces import repository
from .utils import stringutil
urlerr = util.urlerr
@@ -1965,7 +1966,7 @@
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 @@
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 @@
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')
--- a/mercurial/changegroup.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/changegroup.py Sat Aug 08 15:48:17 2020 +0530
@@ -949,7 +949,7 @@
# 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 @@
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 @@
# 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
--- a/mercurial/cmdutil.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/cmdutil.py Sat Aug 08 15:48:17 2020 +0530
@@ -58,6 +58,8 @@
vfs as vfsmod,
)
+from .interfaces import repository
+
from .utils import (
dateutil,
stringutil,
@@ -1358,7 +1360,7 @@
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 "
--- a/mercurial/exchange.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/exchange.py Sat Aug 08 15:48:17 2020 +0530
@@ -1068,7 +1068,7 @@
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 @@
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:
--- a/mercurial/interfaces/repository.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/interfaces/repository.py Sat Aug 08 15:48:17 2020 +0530
@@ -22,6 +22,9 @@
# 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.
--- a/mercurial/localrepo.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/localrepo.py Sat Aug 08 15:48:17 2020 +0530
@@ -846,7 +846,7 @@
"""
options = {}
- if b'treemanifest' in requirements:
+ if repository.TREEMANIFEST_REQUIREMENT in requirements:
options[b'treemanifest'] = True
# experimental config: format.manifestcachesize
@@ -1053,7 +1053,7 @@
supportedformats = {
b'revlogv1',
b'generaldelta',
- b'treemanifest',
+ repository.TREEMANIFEST_REQUIREMENT,
COPIESSDC_REQUIREMENT,
REVLOGV2_REQUIREMENT,
SIDEDATA_REQUIREMENT,
@@ -3314,7 +3314,7 @@
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':
--- a/mercurial/repair.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/repair.py Sat Aug 08 15:48:17 2020 +0530
@@ -28,6 +28,7 @@
pycompat,
util,
)
+from .interfaces import repository
from .utils import (
hashutil,
stringutil,
@@ -418,7 +419,7 @@
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 @@
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):
--- a/mercurial/upgrade.py Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/upgrade.py Sat Aug 08 15:48:17 2020 +0530
@@ -26,6 +26,7 @@
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 @@
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',