D10105: requirements: add constant for revlog v1 requirement
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Thu Mar 4 08:32:55 UTC 2021
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Since this series is adding a new requirement, we might as well clean up while
we're here.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10105
AFFECTED FILES
mercurial/exchangev2.py
mercurial/localrepo.py
mercurial/requirements.py
mercurial/streamclone.py
mercurial/upgrade_utils/actions.py
mercurial/wireprotov1server.py
CHANGE DETAILS
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -27,6 +27,7 @@
exchange,
pushkey as pushkeymod,
pycompat,
+ requirements as requirementsmod,
streamclone,
util,
wireprototypes,
@@ -310,7 +311,7 @@
caps.append(b'stream-preferred')
requiredformats = repo.requirements & repo.supportedformats
# if our local revlogs are just revlogv1, add 'stream' cap
- if not requiredformats - {b'revlogv1'}:
+ if not requiredformats - {requirementsmod.REVLOGV1_REQUIREMENT}:
caps.append(b'stream')
# otherwise, add 'streamreqs' detailing our local revlog format
else:
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
@@ -857,7 +857,7 @@
"""
return {
# Introduced in Mercurial 0.9.2.
- b'revlogv1',
+ requirements.REVLOGV1_REQUIREMENT,
# Introduced in Mercurial 0.9.2.
b'store',
}
@@ -937,7 +937,7 @@
b'dotencode',
b'fncache',
b'generaldelta',
- b'revlogv1',
+ requirements.REVLOGV1_REQUIREMENT,
b'store',
requirements.SPARSEREVLOG_REQUIREMENT,
requirements.SIDEDATA_REQUIREMENT,
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -20,6 +20,7 @@
narrowspec,
phases,
pycompat,
+ requirements as requirementsmod,
scmutil,
store,
util,
@@ -83,7 +84,7 @@
# is advertised and contains a comma-delimited list of requirements.
requirements = set()
if remote.capable(b'stream'):
- requirements.add(b'revlogv1')
+ requirements.add(requirementsmod.REVLOGV1_REQUIREMENT)
else:
streamreqs = remote.capable(b'streamreqs')
# This is weird and shouldn't happen with modern servers.
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -21,6 +21,8 @@
# Stores manifest in Tree structure
TREEMANIFEST_REQUIREMENT = b'treemanifest'
+REVLOGV1_REQUIREMENT = b'revlogv1'
+
# Increment the sub-version when the revlog v2 format changes to lock out old
# clients.
REVLOGV2_REQUIREMENT = b'exp-revlogv2.1'
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -974,7 +974,7 @@
# opener options for it because those options wouldn't do anything
# meaningful on such old repos.
if (
- b'revlogv1' in requirements
+ requirementsmod.REVLOGV1_REQUIREMENT in requirements
or requirementsmod.REVLOGV2_REQUIREMENT in requirements
):
options.update(resolverevlogstorevfsoptions(ui, requirements, features))
@@ -998,7 +998,7 @@
options = {}
options[b'flagprocessors'] = {}
- if b'revlogv1' in requirements:
+ if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
options[b'revlogv1'] = True
if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
options[b'revlogv2'] = True
@@ -1199,7 +1199,7 @@
# being successful (repository sizes went up due to worse delta
# chains), and the code was deleted in 4.6.
supportedformats = {
- b'revlogv1',
+ requirementsmod.REVLOGV1_REQUIREMENT,
b'generaldelta',
requirementsmod.TREEMANIFEST_REQUIREMENT,
requirementsmod.COPIESSDC_REQUIREMENT,
@@ -3410,7 +3410,7 @@
% createopts[b'backend']
)
- requirements = {b'revlogv1'}
+ requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
if ui.configbool(b'format', b'usestore'):
requirements.add(b'store')
if ui.configbool(b'format', b'usefncache'):
@@ -3458,7 +3458,7 @@
revlogv2 = ui.config(b'experimental', b'revlogv2')
if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
- requirements.remove(b'revlogv1')
+ requirements.remove(requirementsmod.REVLOGV1_REQUIREMENT)
# generaldelta is implied by revlogv2.
requirements.discard(b'generaldelta')
requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py
--- a/mercurial/exchangev2.py
+++ b/mercurial/exchangev2.py
@@ -22,6 +22,7 @@
narrowspec,
phases,
pycompat,
+ requirements as requirementsmod,
setdiscovery,
)
from .interfaces import repository
@@ -183,7 +184,7 @@
# TODO This is super hacky. There needs to be a storage API for this. We
# also need to check for compatibility with the remote.
- if b'revlogv1' not in repo.requirements:
+ if requirementsmod.REVLOGV1_REQUIREMENT not in repo.requirements:
return False
return True
To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list