dirstate-v2: Add a new experimental `exp-dirstate-v2` repository requirement
This requirement is added to `.hg/requires` when creating a new repository
if Rust extensions are enabled and the `format.exp-dirstate-v2` config is set.
Nothing yet changes based on this requirement, but its mere presence affects
some tests (for example if they print `.hg/requires`). The next two changesets
update tests’ expected outputs accordingly.
There is no CI so far that enables this configuration.
Differential Revision: https://phab.mercurial-scm.org/D10716
--- a/mercurial/configitems.py Fri Apr 16 00:16:43 2021 +0200
+++ b/mercurial/configitems.py Wed May 19 13:14:59 2021 +0200
@@ -1303,6 +1303,14 @@
experimental=True,
)
coreconfigitem(
+ # Enable this dirstate format *when creating a new repository*.
+ # Which format to use for existing repos is controlled by .hg/requires
+ b'format',
+ b'exp-dirstate-v2',
+ default=False,
+ experimental=True,
+)
+coreconfigitem(
b'format',
b'dotencode',
default=True,
--- a/mercurial/dirstate.py Fri Apr 16 00:16:43 2021 +0200
+++ b/mercurial/dirstate.py Wed May 19 13:14:59 2021 +0200
@@ -39,6 +39,8 @@
parsers = policy.importmod('parsers')
rustmod = policy.importrust('dirstate')
+SUPPORTS_DIRSTATE_V2 = rustmod is not None
+
propertycache = util.propertycache
filecache = scmutil.filecache
_rangemask = 0x7FFFFFFF
--- a/mercurial/localrepo.py Fri Apr 16 00:16:43 2021 +0200
+++ b/mercurial/localrepo.py Wed May 19 13:14:59 2021 +0200
@@ -887,6 +887,9 @@
# Start with all requirements supported by this file.
supported = set(localrepository._basesupported)
+ if dirstate.SUPPORTS_DIRSTATE_V2:
+ supported.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
+
# Execute ``featuresetupfuncs`` entries if they belong to an extension
# relevant to this ui instance.
modules = {m.__name__ for n, m in extensions.extensions(ui)}
@@ -3527,6 +3530,18 @@
if ui.configbool(b'format', b'sparse-revlog'):
requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
+ # experimental config: format.exp-dirstate-v2
+ if ui.configbool(b'format', b'exp-dirstate-v2'):
+ if dirstate.SUPPORTS_DIRSTATE_V2:
+ requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
+ else:
+ raise error.Abort(
+ _(
+ b"dirstate v2 format requested by config "
+ b"but not supported (requires Rust extensions)"
+ )
+ )
+
# experimental config: format.exp-use-copies-side-data-changeset
if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
--- a/mercurial/requirements.py Fri Apr 16 00:16:43 2021 +0200
+++ b/mercurial/requirements.py Wed May 19 13:14:59 2021 +0200
@@ -12,6 +12,8 @@
STORE_REQUIREMENT = b'store'
FNCACHE_REQUIREMENT = b'fncache'
+DIRSTATE_V2_REQUIREMENT = b'exp-dirstate-v2'
+
# 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'
@@ -74,9 +76,12 @@
# repo. Hence both of them should be stored in working copy
# * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of
# the requirements are stored in store's requires
+# * DIRSTATE_V2_REQUIREMENT affects .hg/dirstate, of which there is one per
+# working directory.
WORKING_DIR_REQUIREMENTS = {
SPARSE_REQUIREMENT,
SHARED_REQUIREMENT,
RELATIVE_SHARED_REQUIREMENT,
SHARESAFE_REQUIREMENT,
+ DIRSTATE_V2_REQUIREMENT,
}
--- a/mercurial/upgrade_utils/actions.py Fri Apr 16 00:16:43 2021 +0200
+++ b/mercurial/upgrade_utils/actions.py Wed May 19 13:14:59 2021 +0200
@@ -982,6 +982,7 @@
requirements.SHARESAFE_REQUIREMENT,
requirements.REVLOGV2_REQUIREMENT,
requirements.CHANGELOGV2_REQUIREMENT,
+ requirements.DIRSTATE_V2_REQUIREMENT,
}
for name in compression.compengines:
engine = compression.compengines[name]