# HG changeset patch # User Pierre-Yves David # Date 2021-01-13 22:07:41 # Node ID 9db6dba1ad79d73cb411f8571a60306b395740b2 # Parent ddb395cd02050eda0a7db836cf52b9673e280ac3 persistent-nodemap: add a "warn" option to the slow-path config And make it the default until we get an abort option. Differential Revision: https://phab.mercurial-scm.org/D9761 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"allow", + default=b"warn", experimental=True, ) diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -1959,8 +1959,9 @@ category impact performance and reposito the feature: ``allow``: Silently use the slower implementation to access the repository. - - Default to "allow" + ``warn``: Warn, but use the slower implementation to access the repository. + + Default to ``warn`` 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 @@ -59,6 +59,7 @@ from . import ( rcutil, repoview, requirements as requirementsmod, + revlog, revset, revsetlang, scmutil, @@ -1047,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'): + if slow_path not in (b'allow', b'warn'): default = ui.config_default( b'storage', b'revlog.persistent-nodemap.slow-path' ) @@ -1059,6 +1060,21 @@ def resolverevlogstorevfsoptions(ui, req if not ui.quiet: ui.warn(_(b'falling back to default value: %s\n') % default) slow_path = default + + msg = _( + b"accessing `persistent-nodemap` repository without associated " + b"fast implementation." + ) + hint = _( + 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) 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/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -161,6 +161,16 @@ def _verify_revision(rl, skipflags, stat rl.revision(node) +# True if a fast implementation for persistent-nodemap is available +# +# We also consider we have a "fast" implementation in "pure" python because +# people using pure don't really have performance consideration (and a +# wheelbarrow of other slowness source) +HAS_FAST_PERSISTENT_NODEMAP = rustrevlog is not None or util.safehasattr( + parsers, 'BaseIndexObject' +) + + @attr.s(slots=True, frozen=True) class _revisioninfo(object): """Information about a revision that allows building its fulltext 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 @@ -8,8 +8,30 @@ Test the persistent on-disk nodemap > [devel] > persistent-nodemap=yes > EOF - $ hg init test-repo + + $ hg init test-repo --config storage.revlog.persistent-nodemap.slow-path=allow $ cd test-repo + +Check handling of the default slow-path value + +#if no-pure no-rust + + $ hg id + warning: accessing `persistent-nodemap` repository without associated fast implementation. + (check `hg help config.format.use-persistent-nodemap` for details) + 000000000000 tip + +Unlock further check (we are here to test the feature) + + $ cat << EOF >> $HGRCPATH + > [storage] + > # to avoid spamming the test + > revlog.persistent-nodemap.slow-path=allow + > EOF + +#endif + + $ hg debugformat format-variant repo fncache: yes @@ -23,9 +45,8 @@ Test the persistent on-disk nodemap plain-cl-delta: yes compression: zlib compression-level: default - $ hg debugbuilddag .+5000 --new-file --config "storage.revlog.nodemap.mode=warn" - persistent nodemap in strict mode without efficient method (no-rust no-pure !) - persistent nodemap in strict mode without efficient method (no-rust no-pure !) + $ hg debugbuilddag .+5000 --new-file + $ hg debugnodemap --metadata uid: ???????????????? (glob) tip-rev: 5000 @@ -116,11 +137,22 @@ Check slow-path config value handling $ 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: allow + 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 + $ hg log -r . --config "storage.revlog.persistent-nodemap.slow-path=warn" + warning: accessing `persistent-nodemap` repository without associated fast implementation. + (check `hg help config.format.use-persistent-nodemap` for details) + changeset: 5000:6b02b8c7b966 + tag: tip + user: debugbuilddag + 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 diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t --- a/tests/test-share-safe.t +++ b/tests/test-share-safe.t @@ -5,6 +5,8 @@ setup > share = > [format] > exp-share-safe = True + > [storage] + > revlog.persistent-nodemap.slow-path=allow > EOF prepare source repo