##// END OF EJS Templates
delta-find: add a delta-reuse policy that blindly accepts incoming deltas...
marmoute -
r50662:bcae90c5 default
parent child Browse files
Show More
@@ -1948,6 +1948,13 b' The following sub-options can be defined'
1948 unbundling process, but can result in sub-optimal storage space if the
1948 unbundling process, but can result in sub-optimal storage space if the
1949 remote peer is sending poor quality deltas.
1949 remote peer is sending poor quality deltas.
1950
1950
1951 - ``forced``: the deltas from the peer will be reused in all cases, even if
1952 the resulting delta-chain is "invalid". This setting will ensure the bundle
1953 is applied at minimal CPU cost, but it can result in longer delta chains
1954 being created on the client, making revisions potentially slower to access
1955 in the future. If you think you need this option, you should make sure you
1956 are also talking to the Mercurial developer community to get confirmation.
1957
1951 See `hg help config.storage.revlog.reuse-external-delta-parent` for a similar
1958 See `hg help config.storage.revlog.reuse-external-delta-parent` for a similar
1952 global option. That option defines the behavior of `default`.
1959 global option. That option defines the behavior of `default`.
1953
1960
@@ -315,3 +315,4 b' DELTA_BASE_REUSE_NO = 0'
315 # The delta base will be tested for validy first. So that the cached deltas get
315 # The delta base will be tested for validy first. So that the cached deltas get
316 # used when possible.
316 # used when possible.
317 DELTA_BASE_REUSE_TRY = 1
317 DELTA_BASE_REUSE_TRY = 1
318 DELTA_BASE_REUSE_FORCE = 2
@@ -20,6 +20,7 b' from .constants import ('
20 COMP_MODE_DEFAULT,
20 COMP_MODE_DEFAULT,
21 COMP_MODE_INLINE,
21 COMP_MODE_INLINE,
22 COMP_MODE_PLAIN,
22 COMP_MODE_PLAIN,
23 DELTA_BASE_REUSE_FORCE,
23 DELTA_BASE_REUSE_NO,
24 DELTA_BASE_REUSE_NO,
24 KIND_CHANGELOG,
25 KIND_CHANGELOG,
25 KIND_FILELOG,
26 KIND_FILELOG,
@@ -584,6 +585,13 b' def is_good_delta_info(revlog, deltainfo'
584 if deltainfo is None:
585 if deltainfo is None:
585 return False
586 return False
586
587
588 if (
589 revinfo.cachedelta is not None
590 and deltainfo.base == revinfo.cachedelta[0]
591 and revinfo.cachedelta[2] == DELTA_BASE_REUSE_FORCE
592 ):
593 return True
594
587 # - 'deltainfo.distance' is the distance from the base revision --
595 # - 'deltainfo.distance' is the distance from the base revision --
588 # bounding it limits the amount of I/O we need to do.
596 # bounding it limits the amount of I/O we need to do.
589 # - 'deltainfo.compresseddeltalen' is the sum of the total size of
597 # - 'deltainfo.compresseddeltalen' is the sum of the total size of
@@ -711,6 +719,16 b' def _candidategroups('
711 # filter out revision we tested already
719 # filter out revision we tested already
712 if rev in tested:
720 if rev in tested:
713 continue
721 continue
722
723 if (
724 cachedelta is not None
725 and rev == cachedelta[0]
726 and cachedelta[2] == DELTA_BASE_REUSE_FORCE
727 ):
728 # instructions are to forcibly consider/use this delta base
729 group.append(rev)
730 continue
731
714 # an higher authority deamed the base unworthy (e.g. censored)
732 # an higher authority deamed the base unworthy (e.g. censored)
715 if excluded_bases is not None and rev in excluded_bases:
733 if excluded_bases is not None and rev in excluded_bases:
716 tested.add(rev)
734 tested.add(rev)
@@ -775,6 +775,7 b' DELTA_REUSE_POLICIES = {'
775 b'default': None,
775 b'default': None,
776 b'try-base': revlog_constants.DELTA_BASE_REUSE_TRY,
776 b'try-base': revlog_constants.DELTA_BASE_REUSE_TRY,
777 b'no-reuse': revlog_constants.DELTA_BASE_REUSE_NO,
777 b'no-reuse': revlog_constants.DELTA_BASE_REUSE_NO,
778 b'forced': revlog_constants.DELTA_BASE_REUSE_FORCE,
778 }
779 }
779
780
780
781
@@ -260,3 +260,57 b' We requested to use the (bad) delta'
260 DBG-DELTAS: CHANGELOG: * (glob)
260 DBG-DELTAS: CHANGELOG: * (glob)
261 DBG-DELTAS: MANIFESTLOG: * (glob)
261 DBG-DELTAS: MANIFESTLOG: * (glob)
262 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
262 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
263
264 Case where we force a "bad" delta to be applied
265 ===============================================
266
267 We build a very different file content to force a full snapshot
268
269 $ cp -ar peer-bad-delta peer-bad-delta-with-full
270 $ cp -ar local-pre-pull local-pre-pull-full
271 $ echo '[paths]' >> local-pre-pull-full/.hg/hgrc
272 $ echo 'default=../peer-bad-delta-with-full' >> local-pre-pull-full/.hg/hgrc
273
274 $ hg -R peer-bad-delta-with-full update 'desc("merge")' --quiet
275 $ ($TESTDIR/seq.py 2000 2100; $TESTDIR/seq.py 500 510; $TESTDIR/seq.py 3000 3050) \
276 > | $PYTHON $TESTTMP/sha256line.py > peer-bad-delta-with-full/my-file.txt
277 $ hg -R peer-bad-delta-with-full commit -m 'trigger-full'
278 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=4 * (glob)
279 DBG-DELTAS: MANIFESTLOG: * (glob)
280 DBG-DELTAS: CHANGELOG: * (glob)
281
282 Check that "try-base" behavior challenge the delta
283 --------------------------------------------------
284
285 The bundling process creates a delta against the previous revision, however this
286 is an invalid chain for the client, so it is not considered and we do a full
287 snapshot again.
288
289 $ cp -ar local-pre-pull-full local-try-base-full
290 $ hg -R local-try-base-full pull --quiet \
291 > --config 'paths.default:delta-reuse-policy=try-base'
292 DBG-DELTAS: CHANGELOG: * (glob)
293 DBG-DELTAS: CHANGELOG: * (glob)
294 DBG-DELTAS: MANIFESTLOG: * (glob)
295 DBG-DELTAS: MANIFESTLOG: * (glob)
296 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
297 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=4 * (glob)
298
299 Check that "forced" behavior do not challenge the delta, even if it is bad.
300 ---------------------------------------------------------------------------
301
302 The client does not challenge anything and applies the bizarre delta directly.
303
304 Note: If the bundling process becomes smarter, this test might no longer work
305 (as the server won't be sending "bad" deltas anymore) and might need something
306 more subtle to test this behavior.
307
308 $ cp -ar local-pre-pull-full local-forced-full
309 $ hg -R local-forced-full pull --quiet \
310 > --config 'paths.default:delta-reuse-policy=forced'
311 DBG-DELTAS: CHANGELOG: * (glob)
312 DBG-DELTAS: CHANGELOG: * (glob)
313 DBG-DELTAS: MANIFESTLOG: * (glob)
314 DBG-DELTAS: MANIFESTLOG: * (glob)
315 DBG-DELTAS: FILELOG:my-file.txt: rev=3: delta-base=2 * (glob)
316 DBG-DELTAS: FILELOG:my-file.txt: rev=4: delta-base=3 * (glob)
General Comments 0
You need to be logged in to leave comments. Login now