persistent-nodemap: add a "abort" option to the slow-path config
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 13 Jan 2021 23:41:37 +0100
changeset 46311 014ac7a32048
parent 46310 fc2d5c0aed7f
child 46312 28899b6f4480
persistent-nodemap: add a "abort" option to the slow-path config We make it the default, and document the behavior in the help for the main config option. Differential Revision: https://phab.mercurial-scm.org/D9762
mercurial/configitems.py
mercurial/helptext/config.txt
mercurial/localrepo.py
tests/test-persistent-nodemap.t
--- a/mercurial/configitems.py	Wed Jan 13 23:07:41 2021 +0100
+++ b/mercurial/configitems.py	Wed Jan 13 23:41:37 2021 +0100
@@ -1797,7 +1797,7 @@
 coreconfigitem(
     b'storage',
     b'revlog.persistent-nodemap.slow-path',
-    default=b"warn",
+    default=b"abort",
     experimental=True,
 )
 
--- a/mercurial/helptext/config.txt	Wed Jan 13 23:07:41 2021 +0100
+++ b/mercurial/helptext/config.txt	Wed Jan 13 23:41:37 2021 +0100
@@ -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`.
--- a/mercurial/localrepo.py	Wed Jan 13 23:07:41 2021 +0100
+++ b/mercurial/localrepo.py	Wed Jan 13 23:41:37 2021 +0100
@@ -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
--- a/tests/test-persistent-nodemap.t	Wed Jan 13 23:07:41 2021 +0100
+++ b/tests/test-persistent-nodemap.t	Wed Jan 13 23:41:37 2021 +0100
@@ -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'