# HG changeset patch # User Pierre-Yves David # Date 2021-01-13 22:41:37 # Node ID 014ac7a32048e3b133dbe97f9a91df68d2e8d343 # Parent fc2d5c0aed7f3b094f37f4bab1d26bb3f2cbccb2 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 diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1797,7 +1797,7 @@ coreconfigitem( coreconfigitem( b'storage', b'revlog.persistent-nodemap.slow-path', - default=b"warn", + default=b"abort", experimental=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 @@ https://www.mercurial-scm.org/wiki/Missi 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 @@ category impact performance and reposito ``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/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1048,7 +1048,7 @@ def resolverevlogstorevfsoptions(ui, req 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 @@ def resolverevlogstorevfsoptions(ui, req 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/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 @@ Check handling of the default slow-path #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 @@ add a new commit 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 @@ Check slow-path config value handling 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'