##// END OF EJS Templates
delta-find: add a `delta-reuse-policy` on configuration `path`...
marmoute -
r50661:f1887500 default
parent child Browse files
Show More
@@ -517,6 +517,10 b' def processparts(repo, op, unbundler):'
517
517
518
518
519 def _processchangegroup(op, cg, tr, source, url, **kwargs):
519 def _processchangegroup(op, cg, tr, source, url, **kwargs):
520 if op.remote is not None and op.remote.path is not None:
521 remote_path = op.remote.path
522 kwargs = kwargs.copy()
523 kwargs['delta_base_reuse_policy'] = remote_path.delta_reuse_policy
520 ret = cg.apply(op.repo, tr, source, url, **kwargs)
524 ret = cg.apply(op.repo, tr, source, url, **kwargs)
521 op.records.add(
525 op.records.add(
522 b'changegroup',
526 b'changegroup',
@@ -1922,6 +1922,35 b' The following sub-options can be defined'
1922 - ``ignore``: ignore bookmarks during exchange.
1922 - ``ignore``: ignore bookmarks during exchange.
1923 (This currently only affect pulling)
1923 (This currently only affect pulling)
1924
1924
1925 .. container:: verbose
1926
1927 ``delta-reuse-policy``
1928 Control the policy regarding deltas sent by the remote during pulls.
1929
1930 This is an advanced option that non-admin users should not need to understand
1931 or set. This option can be used to speed up pulls from trusted central
1932 servers, or to fix-up deltas from older servers.
1933
1934 It supports the following values:
1935
1936 - ``default``: use the policy defined by
1937 `storage.revlog.reuse-external-delta-parent`,
1938
1939 - ``no-reuse``: start a new optimal delta search for each new revision we add
1940 to the repository. The deltas from the server will be reused when the base
1941 it applies to is tested (this can be frequent if that base is the one and
1942 unique parent of that revision). This can significantly slowdown pulls but
1943 will result in an optimized storage space if the remote peer is sending poor
1944 quality deltas.
1945
1946 - ``try-base``: try to reuse the deltas from the remote peer as long as they
1947 create a valid delta-chain in the local repository. This speeds up the
1948 unbundling process, but can result in sub-optimal storage space if the
1949 remote peer is sending poor quality deltas.
1950
1951 See `hg help config.storage.revlog.reuse-external-delta-parent` for a similar
1952 global option. That option defines the behavior of `default`.
1953
1925 The following special named paths exist:
1954 The following special named paths exist:
1926
1955
1927 ``default``
1956 ``default``
@@ -24,6 +24,10 b' from . import ('
24 stringutil,
24 stringutil,
25 )
25 )
26
26
27 from ..revlogutils import (
28 constants as revlog_constants,
29 )
30
27
31
28 if pycompat.TYPE_CHECKING:
32 if pycompat.TYPE_CHECKING:
29 from typing import (
33 from typing import (
@@ -767,6 +771,26 b' def bookmarks_mode_option(ui, path, valu'
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)
@@ -191,3 +191,72 b' against the "best" parent. (so not the s'
191 \s*1001 (re)
191 \s*1001 (re)
192 $ hg -R bundle-reuse-disabled debugdata my-file.txt 1 | wc -l
192 $ hg -R bundle-reuse-disabled debugdata my-file.txt 1 | wc -l
193 \s*1200 (re)
193 \s*1200 (re)
194
195
196 Check the path.*:delta-reuse-policy option
197 ==========================================
198
199 Get a repository with the bad parent picked and a clone ready to pull the merge
200
201 $ cp -ar bundle-reuse-enabled peer-bad-delta
202 $ hg clone peer-bad-delta local-pre-pull --rev `cat large.node` --rev `cat small.node` --quiet
203 DBG-DELTAS: CHANGELOG: * (glob)
204 DBG-DELTAS: CHANGELOG: * (glob)
205 DBG-DELTAS: CHANGELOG: * (glob)
206 DBG-DELTAS: MANIFESTLOG: * (glob)
207 DBG-DELTAS: MANIFESTLOG: * (glob)
208 DBG-DELTAS: MANIFESTLOG: * (glob)
209 DBG-DELTAS: FILELOG:my-file.txt: rev=0: delta-base=0 * (glob)
210 DBG-DELTAS: FILELOG:my-file.txt: rev=1: delta-base=0 * (glob)
211 DBG-DELTAS: FILELOG:my-file.txt: rev=2: delta-base=0 * (glob)
212
213 Check the parent order for the file
214
215 $ hg -R local-pre-pull debugdata my-file.txt 2 | wc -l
216 \s*1001 (re)
217 $ hg -R local-pre-pull debugdata my-file.txt 1 | wc -l
218 \s*1200 (re)
219
220 Pull with no value (so the default)
221 -----------------------------------
222
223 default is to reuse the (bad) delta
224
225 $ cp -ar local-pre-pull local-no-value
226 $ hg -R local-no-value pull --quiet
227 DBG-DELTAS: CHANGELOG: * (glob)
228 DBG-DELTAS: MANIFESTLOG: * (glob)
229 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
230
231 Pull with explicitly the default
232 --------------------------------
233
234 default is to reuse the (bad) delta
235
236 $ cp -ar local-pre-pull local-default
237 $ hg -R local-default pull --quiet --config 'paths.default:delta-reuse-policy=default'
238 DBG-DELTAS: CHANGELOG: * (glob)
239 DBG-DELTAS: MANIFESTLOG: * (glob)
240 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
241
242 Pull with no-reuse
243 ------------------
244
245 We don't reuse the base, so we get a better delta
246
247 $ cp -ar local-pre-pull local-no-reuse
248 $ hg -R local-no-reuse pull --quiet --config 'paths.default:delta-reuse-policy=no-reuse'
249 DBG-DELTAS: CHANGELOG: * (glob)
250 DBG-DELTAS: MANIFESTLOG: * (glob)
251 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=1 * (glob)
252
253 Pull with try-base
254 ------------------
255
256 We requested to use the (bad) delta
257
258 $ cp -ar local-pre-pull local-try-base
259 $ hg -R local-try-base pull --quiet --config 'paths.default:delta-reuse-policy=try-base'
260 DBG-DELTAS: CHANGELOG: * (glob)
261 DBG-DELTAS: MANIFESTLOG: * (glob)
262 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
General Comments 0
You need to be logged in to leave comments. Login now