Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/urlutil.py @ 49767: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 |
comparison
equal
deleted
inserted
replaced
49766:152d9c011bcd | 49767:f1887500f3ec |
---|---|
20 urllibcompat, | 20 urllibcompat, |
21 ) | 21 ) |
22 | 22 |
23 from . import ( | 23 from . import ( |
24 stringutil, | 24 stringutil, |
25 ) | |
26 | |
27 from ..revlogutils import ( | |
28 constants as revlog_constants, | |
25 ) | 29 ) |
26 | 30 |
27 | 31 |
28 if pycompat.TYPE_CHECKING: | 32 if pycompat.TYPE_CHECKING: |
29 from typing import ( | 33 from typing import ( |
765 if value == b'default': | 769 if value == b'default': |
766 value = None | 770 value = None |
767 return value | 771 return value |
768 | 772 |
769 | 773 |
774 DELTA_REUSE_POLICIES = { | |
775 b'default': None, | |
776 b'try-base': revlog_constants.DELTA_BASE_REUSE_TRY, | |
777 b'no-reuse': revlog_constants.DELTA_BASE_REUSE_NO, | |
778 } | |
779 | |
780 | |
781 @pathsuboption(b'delta-reuse-policy', b'delta_reuse_policy') | |
782 def delta_reuse_policy(ui, path, value): | |
783 if value not in DELTA_REUSE_POLICIES: | |
784 path_name = path.name | |
785 if path_name is None: | |
786 # this is an "anonymous" path, config comes from the global one | |
787 path_name = b'*' | |
788 msg = _(b'(paths.%s:delta-reuse-policy has unknown value: "%s")\n') | |
789 msg %= (path_name, value) | |
790 ui.warn(msg) | |
791 return DELTA_REUSE_POLICIES.get(value) | |
792 | |
793 | |
770 @pathsuboption(b'multi-urls', b'multi_urls') | 794 @pathsuboption(b'multi-urls', b'multi_urls') |
771 def multiurls_pathoption(ui, path, value): | 795 def multiurls_pathoption(ui, path, value): |
772 res = stringutil.parsebool(value) | 796 res = stringutil.parsebool(value) |
773 if res is None: | 797 if res is None: |
774 ui.warn( | 798 ui.warn( |