Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 48247:5c567aca080d
dirstate-v2: add an option to prevent unintentional slow dirstate-v2
This is the project policy discussed in November 2020 and already put to use for
the persistent nodemap.
Differential Revision: https://phab.mercurial-scm.org/D11668
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 15 Oct 2021 01:27:39 +0200 |
parents | b4f83c9e7905 |
children | bf11ff22a9af |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Oct 14 22:35:46 2021 -0700 +++ b/mercurial/localrepo.py Fri Oct 15 01:27:39 2021 +0200 @@ -1174,6 +1174,32 @@ if slow_path == b'abort': raise error.Abort(msg, hint=hint) options[b'persistent-nodemap'] = True + if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements: + slow_path = ui.config(b'storage', b'dirstate-v2.slow-path') + if slow_path not in (b'allow', b'warn', b'abort'): + default = ui.config_default(b'storage', b'dirstate-v2.slow-path') + msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n') + ui.warn(msg % slow_path) + if not ui.quiet: + ui.warn(_(b'falling back to default value: %s\n') % default) + slow_path = default + + msg = _( + b"accessing `dirstate-v2` repository without associated " + b"fast implementation." + ) + hint = _( + b"check `hg help config.format.exp-dirstate-v2` " b"for details" + ) + if not dirstate.HAS_FAST_DIRSTATE_V2: + 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) if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'): options[b'persistent-nodemap.mmap'] = True if ui.configbool(b'devel', b'persistent-nodemap'):