Show More
@@ -742,83 +742,82 b' class _DeltaSearch:' | |||||
742 |
|
742 | |||
743 | def _pre_filter_rev(self, rev): |
|
743 | def _pre_filter_rev(self, rev): | |
744 | """return True if it seems okay to test a rev, False otherwise""" |
|
744 | """return True if it seems okay to test a rev, False otherwise""" | |
745 | if True: |
|
745 | # no need to try a delta against nullrev, this will be done as | |
746 | # no need to try a delta against nullrev, this will be done as |
|
746 | # a last resort. | |
747 | # a last resort. |
|
747 | if rev == nullrev: | |
748 |
|
|
748 | return False | |
749 | return False |
|
749 | # filter out revision we tested already | |
750 | # filter out revision we tested already |
|
750 | if rev in self.tested: | |
751 |
|
|
751 | return False | |
752 | return False |
|
|||
753 |
|
752 | |||
754 |
|
|
753 | # an higher authority deamed the base unworthy (e.g. censored) | |
755 |
|
|
754 | if self.excluded_bases is not None and rev in self.excluded_bases: | |
756 |
|
|
755 | return False | |
757 |
|
|
756 | # We are in some recomputation cases and that rev is too high | |
758 |
|
|
757 | # in the revlog | |
759 |
|
|
758 | if self.target_rev is not None and rev >= self.target_rev: | |
760 |
|
|
759 | return False | |
761 |
|
760 | |||
762 |
|
|
761 | deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT | |
763 |
|
|
762 | # filter out delta base that will never produce good delta | |
764 |
|
|
763 | # | |
765 |
|
|
764 | # if the delta of that base is already bigger than the limit | |
766 |
|
|
765 | # for the delta chain size, doing a delta is hopeless. | |
767 |
|
|
766 | if deltas_limit < self.revlog.length(rev): | |
768 |
|
|
767 | return False | |
769 |
|
768 | |||
770 |
|
|
769 | sparse = self.revlog.delta_config.sparse_revlog | |
771 |
|
|
770 | # if the revision we test again is too small, the resulting delta | |
772 |
|
|
771 | # will be large anyway as that amount of data to be added is big | |
773 |
|
|
772 | if sparse and self.revlog.rawsize(rev) < ( | |
774 |
|
|
773 | self.textlen // LIMIT_BASE2TEXT | |
775 |
|
|
774 | ): | |
776 |
|
|
775 | return False | |
777 |
|
776 | |||
778 |
|
|
777 | # no delta for rawtext-changing revs (see "candelta" for why) | |
779 |
|
|
778 | if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS: | |
780 |
|
|
779 | return False | |
781 |
|
780 | |||
782 |
|
|
781 | # If we reach here, we are about to build and test a delta. | |
783 |
|
|
782 | # The delta building process will compute the chaininfo in all | |
784 |
|
|
783 | # case, since that computation is cached, it is fine to access | |
785 |
|
|
784 | # it here too. | |
786 |
|
|
785 | chainlen, chainsize = self.revlog._chaininfo(rev) | |
787 |
|
|
786 | # if chain will be too long, skip base | |
788 |
|
|
787 | if ( | |
789 |
|
|
788 | self.revlog.delta_config.max_chain_len | |
790 |
|
|
789 | and chainlen >= self.revlog.delta_config.max_chain_len | |
791 |
|
|
790 | ): | |
792 |
|
|
791 | return False | |
793 |
|
|
792 | # if chain already have too much data, skip base | |
794 |
|
|
793 | if deltas_limit < chainsize: | |
795 |
|
|
794 | return False | |
796 |
|
|
795 | if sparse and self.revlog.delta_config.upper_bound_comp is not None: | |
797 |
|
|
796 | maxcomp = self.revlog.delta_config.upper_bound_comp | |
798 |
|
|
797 | basenotsnap = (self.p1, self.p2, nullrev) | |
799 |
|
|
798 | if rev not in basenotsnap and self.revlog.issnapshot(rev): | |
800 |
|
|
799 | snapshotdepth = self.revlog.snapshotdepth(rev) | |
801 |
|
|
800 | # If text is significantly larger than the base, we can | |
802 |
|
|
801 | # expect the resulting delta to be proportional to the size | |
803 |
|
|
802 | # difference | |
804 |
|
|
803 | revsize = self.revlog.rawsize(rev) | |
805 |
|
|
804 | rawsizedistance = max(self.textlen - revsize, 0) | |
806 |
|
|
805 | # use an estimate of the compression upper bound. | |
807 |
|
|
806 | lowestrealisticdeltalen = rawsizedistance // maxcomp | |
808 |
|
807 | |||
809 |
|
|
808 | # check the absolute constraint on the delta size | |
810 |
|
|
809 | snapshotlimit = self.textlen >> snapshotdepth | |
811 |
|
|
810 | if snapshotlimit < lowestrealisticdeltalen: | |
812 |
|
|
811 | # delta lower bound is larger than accepted upper | |
813 |
|
|
812 | # bound | |
814 |
|
|
813 | return False | |
815 |
|
814 | |||
816 |
|
|
815 | # check the relative constraint on the delta size | |
817 |
|
|
816 | revlength = self.revlog.length(rev) | |
818 |
|
|
817 | if revlength < lowestrealisticdeltalen: | |
819 |
|
|
818 | # delta probable lower bound is larger than target | |
820 |
|
|
819 | # base | |
821 |
|
|
820 | return False | |
822 | return True |
|
821 | return True | |
823 |
|
822 | |||
824 | def _refined_groups(self): |
|
823 | def _refined_groups(self): |
General Comments 0
You need to be logged in to leave comments.
Login now