Mercurial > hg
comparison mercurial/changegroup.py @ 49766:152d9c011bcd
changegroup: add `delta_base_reuse_policy` argument
The argument available through function from changegroup.apply to
`revlog.apply` allow to override the revlog configuration in terms of
delta-base-reuse policy when searching for a delta to store a revision.
It will be put to use in the next changesets.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 03 Dec 2022 01:31:23 +0100 |
parents | 35d4c2124073 |
children | d718eddf01d9 |
comparison
equal
deleted
inserted
replaced
49765:4188e75af983 | 49766:152d9c011bcd |
---|---|
418 revmap, | 418 revmap, |
419 trp, | 419 trp, |
420 prog, | 420 prog, |
421 addrevisioncb=None, | 421 addrevisioncb=None, |
422 debug_info=None, | 422 debug_info=None, |
423 delta_base_reuse_policy=None, | |
423 ): | 424 ): |
424 self.callback = prog.increment | 425 self.callback = prog.increment |
425 # no need to check for empty manifest group here: | 426 # no need to check for empty manifest group here: |
426 # if the result of the merge of 1 and 2 is the same in 3 and 4, | 427 # if the result of the merge of 1 and 2 is the same in 3 and 4, |
427 # no new manifest will be created and the manifest group will | 428 # no new manifest will be created and the manifest group will |
433 deltas, | 434 deltas, |
434 revmap, | 435 revmap, |
435 trp, | 436 trp, |
436 addrevisioncb=addrevisioncb, | 437 addrevisioncb=addrevisioncb, |
437 debug_info=debug_info, | 438 debug_info=debug_info, |
439 delta_base_reuse_policy=delta_base_reuse_policy, | |
438 ) | 440 ) |
439 prog.complete() | 441 prog.complete() |
440 self.callback = None | 442 self.callback = None |
441 | 443 |
442 def apply( | 444 def apply( |
446 srctype, | 448 srctype, |
447 url, | 449 url, |
448 targetphase=phases.draft, | 450 targetphase=phases.draft, |
449 expectedtotal=None, | 451 expectedtotal=None, |
450 sidedata_categories=None, | 452 sidedata_categories=None, |
453 delta_base_reuse_policy=None, | |
451 ): | 454 ): |
452 """Add the changegroup returned by source.read() to this repo. | 455 """Add the changegroup returned by source.read() to this repo. |
453 srctype is a string like 'push', 'pull', or 'unbundle'. url is | 456 srctype is a string like 'push', 'pull', or 'unbundle'. url is |
454 the URL of the repo where this changegroup is coming from. | 457 the URL of the repo where this changegroup is coming from. |
455 | 458 |
459 - fewer heads than before: -1-removed heads (-2..-n) | 462 - fewer heads than before: -1-removed heads (-2..-n) |
460 - number of heads stays the same: 1 | 463 - number of heads stays the same: 1 |
461 | 464 |
462 `sidedata_categories` is an optional set of the remote's sidedata wanted | 465 `sidedata_categories` is an optional set of the remote's sidedata wanted |
463 categories. | 466 categories. |
467 | |
468 `delta_base_reuse_policy` is an optional argument, when set to a value | |
469 it will control the way the delta contained into the bundle are reused | |
470 when applied in the revlog. | |
471 | |
472 See `DELTA_BASE_REUSE_*` entry in mercurial.revlogutils.constants. | |
464 """ | 473 """ |
465 repo = repo.unfiltered() | 474 repo = repo.unfiltered() |
466 | 475 |
467 debug_info = None | 476 debug_info = None |
468 if repo.ui.configbool(b'debug', b'unbundling-stats'): | 477 if repo.ui.configbool(b'debug', b'unbundling-stats'): |
541 trp, | 550 trp, |
542 alwayscache=True, | 551 alwayscache=True, |
543 addrevisioncb=onchangelog, | 552 addrevisioncb=onchangelog, |
544 duplicaterevisioncb=ondupchangelog, | 553 duplicaterevisioncb=ondupchangelog, |
545 debug_info=debug_info, | 554 debug_info=debug_info, |
555 delta_base_reuse_policy=delta_base_reuse_policy, | |
546 ): | 556 ): |
547 repo.ui.develwarn( | 557 repo.ui.develwarn( |
548 b'applied empty changelog from changegroup', | 558 b'applied empty changelog from changegroup', |
549 config=b'warn-empty-changegroup', | 559 config=b'warn-empty-changegroup', |
550 ) | 560 ) |
589 revmap, | 599 revmap, |
590 trp, | 600 trp, |
591 progress, | 601 progress, |
592 addrevisioncb=on_manifest_rev, | 602 addrevisioncb=on_manifest_rev, |
593 debug_info=debug_info, | 603 debug_info=debug_info, |
604 delta_base_reuse_policy=delta_base_reuse_policy, | |
594 ) | 605 ) |
595 | 606 |
596 needfiles = {} | 607 needfiles = {} |
597 if repo.ui.configbool(b'server', b'validate'): | 608 if repo.ui.configbool(b'server', b'validate'): |
598 cl = repo.changelog | 609 cl = repo.changelog |
626 trp, | 637 trp, |
627 efiles, | 638 efiles, |
628 needfiles, | 639 needfiles, |
629 addrevisioncb=on_filelog_rev, | 640 addrevisioncb=on_filelog_rev, |
630 debug_info=debug_info, | 641 debug_info=debug_info, |
642 delta_base_reuse_policy=delta_base_reuse_policy, | |
631 ) | 643 ) |
632 | 644 |
633 if sidedata_helpers: | 645 if sidedata_helpers: |
634 if revlog_constants.KIND_CHANGELOG in sidedata_helpers[1]: | 646 if revlog_constants.KIND_CHANGELOG in sidedata_helpers[1]: |
635 cl.rewrite_sidedata( | 647 cl.rewrite_sidedata( |
813 revmap, | 825 revmap, |
814 trp, | 826 trp, |
815 prog, | 827 prog, |
816 addrevisioncb=None, | 828 addrevisioncb=None, |
817 debug_info=None, | 829 debug_info=None, |
830 delta_base_reuse_policy=None, | |
818 ): | 831 ): |
819 super(cg3unpacker, self)._unpackmanifests( | 832 super(cg3unpacker, self)._unpackmanifests( |
820 repo, | 833 repo, |
821 revmap, | 834 revmap, |
822 trp, | 835 trp, |
823 prog, | 836 prog, |
824 addrevisioncb=addrevisioncb, | 837 addrevisioncb=addrevisioncb, |
825 debug_info=debug_info, | 838 debug_info=debug_info, |
839 delta_base_reuse_policy=delta_base_reuse_policy, | |
826 ) | 840 ) |
827 for chunkdata in iter(self.filelogheader, {}): | 841 for chunkdata in iter(self.filelogheader, {}): |
828 # If we get here, there are directory manifests in the changegroup | 842 # If we get here, there are directory manifests in the changegroup |
829 d = chunkdata[b"filename"] | 843 d = chunkdata[b"filename"] |
830 repo.ui.debug(b"adding %s revisions\n" % d) | 844 repo.ui.debug(b"adding %s revisions\n" % d) |
833 deltas, | 847 deltas, |
834 revmap, | 848 revmap, |
835 trp, | 849 trp, |
836 addrevisioncb=addrevisioncb, | 850 addrevisioncb=addrevisioncb, |
837 debug_info=debug_info, | 851 debug_info=debug_info, |
852 delta_base_reuse_policy=delta_base_reuse_policy, | |
838 ): | 853 ): |
839 raise error.Abort(_(b"received dir revlog group is empty")) | 854 raise error.Abort(_(b"received dir revlog group is empty")) |
840 | 855 |
841 | 856 |
842 class cg4unpacker(cg3unpacker): | 857 class cg4unpacker(cg3unpacker): |
2370 trp, | 2385 trp, |
2371 expectedfiles, | 2386 expectedfiles, |
2372 needfiles, | 2387 needfiles, |
2373 addrevisioncb=None, | 2388 addrevisioncb=None, |
2374 debug_info=None, | 2389 debug_info=None, |
2390 delta_base_reuse_policy=None, | |
2375 ): | 2391 ): |
2376 revisions = 0 | 2392 revisions = 0 |
2377 files = 0 | 2393 files = 0 |
2378 progress = repo.ui.makeprogress( | 2394 progress = repo.ui.makeprogress( |
2379 _(b'files'), unit=_(b'files'), total=expectedfiles | 2395 _(b'files'), unit=_(b'files'), total=expectedfiles |
2391 deltas, | 2407 deltas, |
2392 revmap, | 2408 revmap, |
2393 trp, | 2409 trp, |
2394 addrevisioncb=addrevisioncb, | 2410 addrevisioncb=addrevisioncb, |
2395 debug_info=debug_info, | 2411 debug_info=debug_info, |
2412 delta_base_reuse_policy=delta_base_reuse_policy, | |
2396 ) | 2413 ) |
2397 if not added: | 2414 if not added: |
2398 raise error.Abort(_(b"received file revlog group is empty")) | 2415 raise error.Abort(_(b"received file revlog group is empty")) |
2399 except error.CensoredBaseError as e: | 2416 except error.CensoredBaseError as e: |
2400 raise error.Abort(_(b"received delta base is censored: %s") % e) | 2417 raise error.Abort(_(b"received delta base is censored: %s") % e) |