[Request] [++ ] D10716: dirstate-v2: Add a new experimental `exp-dirstate-v2` repository requirement

SimonSapin phabricator at mercurial-scm.org
Mon May 17 10:09:09 UTC 2021


SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10716

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dirstate.py
  mercurial/localrepo.py
  mercurial/requirements.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS

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
@@ -971,6 +971,7 @@
         requirements.NODEMAP_REQUIREMENT,
         requirements.SHARESAFE_REQUIREMENT,
         requirements.REVLOGV2_REQUIREMENT,
+        requirements.DIRSTATE_V2_REQUIREMENT,
     }
     for name in compression.compengines:
         engine = compression.compengines[name]
diff --git a/mercurial/requirements.py b/mercurial/requirements.py
--- a/mercurial/requirements.py
+++ b/mercurial/requirements.py
@@ -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'
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -879,6 +879,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)}
@@ -3514,6 +3517,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-side-data
     if ui.configbool(b'format', b'exp-use-side-data'):
         requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1282,6 +1282,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,



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210517/29394b46/attachment.html>


More information about the Mercurial-patches mailing list