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