Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 48793:6e559391f96e
tracked-key: remove the dual write and rename to tracked-hint
The dual-write approach was mostly useless. As explained in the previous version
of the help, the key had to be read twice before we could cache a value.
However this "read twice" limitation actually also apply to any usage of the
key. If some operation wants to rely of the "same value == same tracked set"
property it would need to read the value before, and after running that
operation (or at least, after, in all cases). So it cannot be sure the operation
it did is "valid" until checking the key after the operation. As a resultat such
operation can only be read-only or rollbackable.
This reduce the utility of the "same value == same tracked set" a lot.
So it seems simpler to drop the double write and to update the documentation to
highlight that this file does not garantee race-free operation. As a result the
"key" is demoted to a "hint".
Documentation is updated accordingly.
Differential Revision: https://phab.mercurial-scm.org/D12201
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 17 Feb 2022 07:34:49 +0100 |
parents | 8bbb1abb9d19 |
children | db3f8e5cc965 a0da5075bca3 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Feb 17 06:41:54 2022 +0100 +++ b/mercurial/localrepo.py Thu Feb 17 07:34:49 2022 +0100 @@ -1278,7 +1278,7 @@ requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT, requirementsmod.CHANGELOGV2_REQUIREMENT, requirementsmod.COPIESSDC_REQUIREMENT, - requirementsmod.DIRSTATE_TRACKED_KEY_V1, + requirementsmod.DIRSTATE_TRACKED_HINT_V1, requirementsmod.DIRSTATE_V2_REQUIREMENT, requirementsmod.DOTENCODE_REQUIREMENT, requirementsmod.FNCACHE_REQUIREMENT, @@ -1743,9 +1743,9 @@ """Extension point for wrapping the dirstate per-repo.""" sparsematchfn = lambda: sparse.matcher(self) v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT - tk = requirementsmod.DIRSTATE_TRACKED_KEY_V1 + th = requirementsmod.DIRSTATE_TRACKED_HINT_V1 use_dirstate_v2 = v2_req in self.requirements - use_tracked_key = tk in self.requirements + use_tracked_hint = th in self.requirements return dirstate.dirstate( self.vfs, @@ -1755,7 +1755,7 @@ sparsematchfn, self.nodeconstants, use_dirstate_v2, - use_tracked_key=use_tracked_key, + use_tracked_hint=use_tracked_hint, ) def _dirstatevalidate(self, node): @@ -3695,14 +3695,14 @@ else: requirements.add(requirementsmod.SHARED_REQUIREMENT) - if ui.configbool(b'format', b'use-dirstate-tracked-key'): - version = ui.configint(b'format', b'use-dirstate-tracked-key.version') + if ui.configbool(b'format', b'use-dirstate-tracked-hint'): + version = ui.configint(b'format', b'use-dirstate-tracked-hint.version') msg = _("ignoring unknown tracked key version: %d\n") - hint = _("see `hg help config.format.use-dirstate-tracked-key-version") + hint = _("see `hg help config.format.use-dirstate-tracked-hint-version") if version != 1: ui.warn(msg % version, hint=hint) else: - requirements.add(requirementsmod.DIRSTATE_TRACKED_KEY_V1) + requirements.add(requirementsmod.DIRSTATE_TRACKED_HINT_V1) return requirements