Show More
@@ -568,7 +568,7 b' def isgooddeltainfo(revlog, deltainfo, r' | |||||
568 |
|
568 | |||
569 | return True |
|
569 | return True | |
570 |
|
570 | |||
571 | def _candidategroups(revlog, p1, p2, cachedelta): |
|
571 | def _candidategroups(revlog, textlen, p1, p2, cachedelta): | |
572 | """Provides group of revision to be tested as delta base |
|
572 | """Provides group of revision to be tested as delta base | |
573 |
|
573 | |||
574 | This top level function focus on emitting groups with unique and worthwhile |
|
574 | This top level function focus on emitting groups with unique and worthwhile | |
@@ -578,12 +578,36 b' def _candidategroups(revlog, p1, p2, cac' | |||||
578 | if not (len(revlog) and revlog._storedeltachains): |
|
578 | if not (len(revlog) and revlog._storedeltachains): | |
579 | return |
|
579 | return | |
580 |
|
580 | |||
|
581 | deltalength = revlog.length | |||
|
582 | deltaparent = revlog.deltaparent | |||
|
583 | ||||
|
584 | deltas_limit = textlen * LIMIT_DELTA2TEXT | |||
|
585 | ||||
581 | tested = set([nullrev]) |
|
586 | tested = set([nullrev]) | |
582 |
for |
|
587 | for temptative in _rawgroups(revlog, p1, p2, cachedelta): | |
583 | group = tuple(r for r in group if r not in tested) |
|
588 | group = [] | |
584 | tested.update(group) |
|
589 | for rev in temptative: | |
|
590 | # skip over empty delta (no need to include them in a chain) | |||
|
591 | while not (rev == nullrev or rev in tested or deltalength(rev)): | |||
|
592 | rev = deltaparent(rev) | |||
|
593 | tested.add(rev) | |||
|
594 | # filter out revision we tested already | |||
|
595 | if rev in tested: | |||
|
596 | continue | |||
|
597 | tested.add(rev) | |||
|
598 | # filter out delta base that will never produce good delta | |||
|
599 | if deltas_limit < revlog.length(rev): | |||
|
600 | continue | |||
|
601 | # no need to try a delta against nullrev, this will be done as a | |||
|
602 | # last resort. | |||
|
603 | if rev == nullrev: | |||
|
604 | continue | |||
|
605 | # no delta for rawtext-changing revs (see "candelta" for why) | |||
|
606 | if revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS: | |||
|
607 | continue | |||
|
608 | group.append(rev) | |||
585 | if group: |
|
609 | if group: | |
586 | yield group |
|
610 | yield tuple(group) | |
587 |
|
611 | |||
588 | def _rawgroups(revlog, p1, p2, cachedelta): |
|
612 | def _rawgroups(revlog, p1, p2, cachedelta): | |
589 | """Provides group of revision to be tested as delta base |
|
613 | """Provides group of revision to be tested as delta base | |
@@ -752,29 +776,13 b' class deltacomputer(object):' | |||||
752 | p2 = revinfo.p2 |
|
776 | p2 = revinfo.p2 | |
753 | revlog = self.revlog |
|
777 | revlog = self.revlog | |
754 |
|
778 | |||
755 | deltalength = self.revlog.length |
|
|||
756 | deltaparent = self.revlog.deltaparent |
|
|||
757 |
|
||||
758 | deltainfo = None |
|
779 | deltainfo = None | |
759 | deltas_limit = revinfo.textlen * LIMIT_DELTA2TEXT |
|
|||
760 | p1r, p2r = revlog.rev(p1), revlog.rev(p2) |
|
780 | p1r, p2r = revlog.rev(p1), revlog.rev(p2) | |
761 |
groups = _candidategroups(self.revlog, |
|
781 | groups = _candidategroups(self.revlog, revinfo.textlen, | |
|
782 | p1r, p2r, cachedelta) | |||
762 | for candidaterevs in groups: |
|
783 | for candidaterevs in groups: | |
763 | # filter out delta base that will never produce good delta |
|
|||
764 | candidaterevs = [r for r in candidaterevs |
|
|||
765 | if self.revlog.length(r) <= deltas_limit] |
|
|||
766 | nominateddeltas = [] |
|
784 | nominateddeltas = [] | |
767 | for candidaterev in candidaterevs: |
|
785 | for candidaterev in candidaterevs: | |
768 | # skip over empty delta (no need to include them in a chain) |
|
|||
769 | while candidaterev != nullrev and not deltalength(candidaterev): |
|
|||
770 | candidaterev = deltaparent(candidaterev) |
|
|||
771 | # no need to try a delta against nullid, this will be handled |
|
|||
772 | # by fulltext later. |
|
|||
773 | if candidaterev == nullrev: |
|
|||
774 | continue |
|
|||
775 | # no delta for rawtext-changing revs (see "candelta" for why) |
|
|||
776 | if revlog.flags(candidaterev) & REVIDX_RAWTEXT_CHANGING_FLAGS: |
|
|||
777 | continue |
|
|||
778 | candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) |
|
786 | candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh) | |
779 | if isgooddeltainfo(self.revlog, candidatedelta, revinfo): |
|
787 | if isgooddeltainfo(self.revlog, candidatedelta, revinfo): | |
780 | nominateddeltas.append(candidatedelta) |
|
788 | nominateddeltas.append(candidatedelta) |
General Comments 0
You need to be logged in to leave comments.
Login now