Commit 80b457ca authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

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
parent 1837663ac216
Pipeline #27825 failed with stages
in 170 minutes and 14 seconds
......@@ -1885,6 +1885,13 @@ coreconfigitem(
default=b'skip',
experimental=True,
)
# experimental as long as format.exp-dirstate-v2 is.
coreconfigitem(
b'storage',
b'dirstate-v2.slow-path',
default=b"abort",
experimental=True,
)
coreconfigitem(
b'storage',
b'new-repo-backend',
......
......@@ -39,6 +39,8 @@ from .interfaces import (
parsers = policy.importmod('parsers')
rustmod = policy.importrust('dirstate')
HAS_FAST_DIRSTATE_V2 = rustmod is not None
propertycache = util.propertycache
filecache = scmutil.filecache
_rangemask = dirstatemap.rangemask
......
......@@ -1174,6 +1174,32 @@ def resolverevlogstorevfsoptions(ui, requirements, features):
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'):
......
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
$ hg init repo
......
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
Checking the size/permissions/file-type of files stored in the
......
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
------ Test dirstate._dirs refcounting
......
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
$ hg init ignorerepo
......
......@@ -3,8 +3,12 @@
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
$ hg init t
......
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
init
......
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
$ hg init repo1
......
......@@ -3,8 +3,12 @@
#testcases dirstate-v1 dirstate-v2
#if dirstate-v2
$ echo '[format]' >> $HGRCPATH
$ echo 'exp-dirstate-v2=1' >> $HGRCPATH
$ cat >> $HGRCPATH << EOF
> [format]
> exp-dirstate-v2=1
> [storage]
> dirstate-v2.slow-path=allow
> EOF
#endif
== tests added in 0.7 ==
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment