Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/deltas.py @ 51335:2407af4f2eea
delta-find: split the generic part of `_pre_filter_rev` in a method
Since `_pre_filter_rev` contains logic from various sources of constraint, we
start splitting is in subfunction to clarify and document the grouping.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 23 Nov 2023 18:56:31 +0100 |
parents | ac8b798e602b |
children | 9a1239c362ae |
comparison
equal
deleted
inserted
replaced
51334:ac8b798e602b | 51335:2407af4f2eea |
---|---|
738 group.append(rev) | 738 group.append(rev) |
739 else: | 739 else: |
740 self.tested.add(rev) | 740 self.tested.add(rev) |
741 return group | 741 return group |
742 | 742 |
743 def _pre_filter_rev(self, rev): | 743 def _pre_filter_rev_universal(self, rev): |
744 """return True if it seems okay to test a rev, False otherwise""" | 744 """pre filtering that is need in all cases. |
745 | |
746 return True if it seems okay to test a rev, False otherwise. | |
747 | |
748 used by _pre_filter_rev. | |
749 """ | |
745 # no need to try a delta against nullrev, this will be done as | 750 # no need to try a delta against nullrev, this will be done as |
746 # a last resort. | 751 # a last resort. |
747 if rev == nullrev: | 752 if rev == nullrev: |
748 return False | 753 return False |
749 # filter out revision we tested already | 754 # filter out revision we tested already |
755 return False | 760 return False |
756 # We are in some recomputation cases and that rev is too high | 761 # We are in some recomputation cases and that rev is too high |
757 # in the revlog | 762 # in the revlog |
758 if self.target_rev is not None and rev >= self.target_rev: | 763 if self.target_rev is not None and rev >= self.target_rev: |
759 return False | 764 return False |
765 # no delta for rawtext-changing revs (see "candelta" for why) | |
766 if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS: | |
767 return False | |
768 return True | |
769 | |
770 def _pre_filter_rev(self, rev): | |
771 """return True if it seems okay to test a rev, False otherwise""" | |
772 if not self._pre_filter_rev_universal(rev): | |
773 return False | |
760 | 774 |
761 deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT | 775 deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT |
762 # filter out delta base that will never produce good delta | 776 # filter out delta base that will never produce good delta |
763 # | 777 # |
764 # if the delta of that base is already bigger than the limit | 778 # if the delta of that base is already bigger than the limit |
770 # if the revision we test again is too small, the resulting delta | 784 # 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 | 785 # will be large anyway as that amount of data to be added is big |
772 if sparse and self.revlog.rawsize(rev) < ( | 786 if sparse and self.revlog.rawsize(rev) < ( |
773 self.textlen // LIMIT_BASE2TEXT | 787 self.textlen // LIMIT_BASE2TEXT |
774 ): | 788 ): |
775 return False | |
776 | |
777 # no delta for rawtext-changing revs (see "candelta" for why) | |
778 if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS: | |
779 return False | 789 return False |
780 | 790 |
781 # If we reach here, we are about to build and test a delta. | 791 # If we reach here, we are about to build and test a delta. |
782 # The delta building process will compute the chaininfo in all | 792 # The delta building process will compute the chaininfo in all |
783 # case, since that computation is cached, it is fine to access | 793 # case, since that computation is cached, it is fine to access |