diff mercurial/localrepo.py @ 47288:ed0d54b20c5b

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
author Simon Sapin <simon.sapin@octobus.net>
date Wed, 19 May 2021 13:14:59 +0200
parents a07381751dc9
children 40b51c28b242
line wrap: on
line diff
--- 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)