Patchwork D9762: persistent-nodemap: add a "abort" option to the slow-path config

login
register
mail settings
Submitter phabricator
Date Jan. 14, 2021, 4:06 a.m.
Message ID <differential-rev-PHID-DREV-o3foibx5f3ipbyfkbsx7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48073/
State Superseded
Headers show

Comments

phabricator - Jan. 14, 2021, 4:06 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We make it the default, and document the behavior in the help for the main
  config option.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/localrepo.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -17,9 +17,9 @@ 
 #if no-pure no-rust
 
   $ hg id
-  warning: accessing `persistent-nodemap` repository without associated fast implementation.
+  abort: accessing `persistent-nodemap` repository without associated fast implementation.
   (check `hg help config.format.use-persistent-nodemap` for details)
-  000000000000 tip
+  [255]
 
 Unlock further check (we are here to test the feature)
 
@@ -135,14 +135,14 @@ 
 Check slow-path config value handling
 -------------------------------------
 
+#if no-pure no-rust
+
   $ hg id --config "storage.revlog.persistent-nodemap.slow-path=invalid-value"
   unknown value for config "storage.revlog.persistent-nodemap.slow-path": "invalid-value"
-  falling back to default value: warn
-  warning: accessing `persistent-nodemap` repository without associated fast implementation. (no-pure no-rust !)
-  (check `hg help config.format.use-persistent-nodemap` for details) (no-pure no-rust !)
-  6b02b8c7b966+ tip
-
-#if no-pure no-rust
+  falling back to default value: abort
+  abort: accessing `persistent-nodemap` repository without associated fast implementation.
+  (check `hg help config.format.use-persistent-nodemap` for details)
+  [255]
 
   $ hg log -r . --config "storage.revlog.persistent-nodemap.slow-path=warn"
   warning: accessing `persistent-nodemap` repository without associated fast implementation.
@@ -153,12 +153,18 @@ 
   date:        Thu Jan 01 01:23:20 1970 +0000
   summary:     r5000
   
-  $ hg ci -m 'foo' --config "storage.revlog.nodemap.mode=strict"
-  transaction abort!
-  rollback completed
-  abort: persistent nodemap in strict mode without efficient method
+  $ hg ci -m 'foo' --config "storage.revlog.persistent-nodemap.slow-path=abort"
+  abort: accessing `persistent-nodemap` repository without associated fast implementation.
+  (check `hg help config.format.use-persistent-nodemap` for details)
   [255]
 
+#else
+
+  $ hg id --config "storage.revlog.persistent-nodemap.slow-path=invalid-value"
+  unknown value for config "storage.revlog.persistent-nodemap.slow-path": "invalid-value"
+  falling back to default value: abort
+  6b02b8c7b966+ tip
+
 #endif
 
   $ hg ci -m 'foo'
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1048,7 +1048,7 @@ 
         slow_path = ui.config(
             b'storage', b'revlog.persistent-nodemap.slow-path'
         )
-        if slow_path not in (b'allow', b'warn'):
+        if slow_path not in (b'allow', b'warn', b'abort'):
             default = ui.config_default(
                 b'storage', b'revlog.persistent-nodemap.slow-path'
             )
@@ -1069,12 +1069,15 @@ 
             b"check `hg help config.format.use-persistent-nodemap` "
             b"for details"
         )
-        if slow_path == b'warn' and not revlog.HAS_FAST_PERSISTENT_NODEMAP:
-            msg = b"warning: " + msg + b'\n'
-            ui.warn(msg)
-            if not ui.quiet:
-                hint = b'(' + hint + b')\n'
-                ui.warn(hint)
+        if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
+            if slow_path == b'warn':
+                msg = b"warning: " + msg + b'\n'
+                ui.warn(msg)
+                if not ui.quiet:
+                    hint = b'(' + hint + b')\n'
+                    ui.warn(hint)
+            if slow_path == b'abort':
+                raise error.Abort(msg, hint=hint)
         options[b'persistent-nodemap'] = True
     if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
         options[b'persistent-nodemap.mmap'] = True
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -904,8 +904,11 @@ 
     operation for larger repository.
 
     The performance improving version of this feature is currently only
-    implemented in Rust, so people using a version of Mercurial compiled
-    without the Rust part might actually suffer some slowdown.
+    implemented in Rust, so people not using a version of Mercurial compiled
+    with the Rust part  might actually suffer some slowdown. For this reason,
+    Such version will by default refuse to access such repositories. That
+    behavior can be controlled by configuration. Check
+    :hg:`help config.storage.revlog.persistent-nodemap.slowpath` for details.
 
     Repository with this on-disk format require Mercurial version 5.4 or above.
 
@@ -1960,8 +1963,7 @@ 
 
     ``allow``: Silently use the slower implementation to access the repository.
     ``warn``: Warn, but use the slower implementation to access the repository.
-
-    Default to ``warn``
+    ``abort``: Prevent access to such repositories. (This is the default)
 
     For details on the "persistent-nodemap" feature, see:
     :hg:`help config format.use-persistent-nodemap`.
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1782,7 +1782,7 @@ 
 coreconfigitem(
     b'storage',
     b'revlog.persistent-nodemap.slow-path',
-    default=b"warn",
+    default=b"abort",
     experimental=True,
 )