Mercurial > public > mercurial-scm > hg-stable
diff mercurial/utils/urlutil.py @ 49878:f1887500f3ec
delta-find: add a `delta-reuse-policy` on configuration `path`
That option allows to control the behavior on a per-path basis, opening the way
to treating pulls from central servers differently than other operations.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 03 Dec 2022 01:24:34 +0100 |
parents | 20f262ab6fd3 |
children | bcae90c53def |
line wrap: on
line diff
--- a/mercurial/utils/urlutil.py Sat Dec 03 01:31:23 2022 +0100 +++ b/mercurial/utils/urlutil.py Sat Dec 03 01:24:34 2022 +0100 @@ -24,6 +24,10 @@ stringutil, ) +from ..revlogutils import ( + constants as revlog_constants, +) + if pycompat.TYPE_CHECKING: from typing import ( @@ -767,6 +771,26 @@ return value +DELTA_REUSE_POLICIES = { + b'default': None, + b'try-base': revlog_constants.DELTA_BASE_REUSE_TRY, + b'no-reuse': revlog_constants.DELTA_BASE_REUSE_NO, +} + + +@pathsuboption(b'delta-reuse-policy', b'delta_reuse_policy') +def delta_reuse_policy(ui, path, value): + if value not in DELTA_REUSE_POLICIES: + path_name = path.name + if path_name is None: + # this is an "anonymous" path, config comes from the global one + path_name = b'*' + msg = _(b'(paths.%s:delta-reuse-policy has unknown value: "%s")\n') + msg %= (path_name, value) + ui.warn(msg) + return DELTA_REUSE_POLICIES.get(value) + + @pathsuboption(b'multi-urls', b'multi_urls') def multiurls_pathoption(ui, path, value): res = stringutil.parsebool(value)