comparison mercurial/localrepo.py @ 48235: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
comparison
equal deleted inserted replaced
48234:1837663ac216 48235:5c567aca080d
1172 hint = b'(' + hint + b')\n' 1172 hint = b'(' + hint + b')\n'
1173 ui.warn(hint) 1173 ui.warn(hint)
1174 if slow_path == b'abort': 1174 if slow_path == b'abort':
1175 raise error.Abort(msg, hint=hint) 1175 raise error.Abort(msg, hint=hint)
1176 options[b'persistent-nodemap'] = True 1176 options[b'persistent-nodemap'] = True
1177 if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements:
1178 slow_path = ui.config(b'storage', b'dirstate-v2.slow-path')
1179 if slow_path not in (b'allow', b'warn', b'abort'):
1180 default = ui.config_default(b'storage', b'dirstate-v2.slow-path')
1181 msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n')
1182 ui.warn(msg % slow_path)
1183 if not ui.quiet:
1184 ui.warn(_(b'falling back to default value: %s\n') % default)
1185 slow_path = default
1186
1187 msg = _(
1188 b"accessing `dirstate-v2` repository without associated "
1189 b"fast implementation."
1190 )
1191 hint = _(
1192 b"check `hg help config.format.exp-dirstate-v2` " b"for details"
1193 )
1194 if not dirstate.HAS_FAST_DIRSTATE_V2:
1195 if slow_path == b'warn':
1196 msg = b"warning: " + msg + b'\n'
1197 ui.warn(msg)
1198 if not ui.quiet:
1199 hint = b'(' + hint + b')\n'
1200 ui.warn(hint)
1201 if slow_path == b'abort':
1202 raise error.Abort(msg, hint=hint)
1177 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'): 1203 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1178 options[b'persistent-nodemap.mmap'] = True 1204 options[b'persistent-nodemap.mmap'] = True
1179 if ui.configbool(b'devel', b'persistent-nodemap'): 1205 if ui.configbool(b'devel', b'persistent-nodemap'):
1180 options[b'devel-force-nodemap'] = True 1206 options[b'devel-force-nodemap'] = True
1181 1207