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