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.
--- a/mercurial/revlogutils/deltas.py Thu Jan 04 14:39:10 2024 +0100
+++ b/mercurial/revlogutils/deltas.py Thu Nov 23 18:56:31 2023 +0100
@@ -740,8 +740,13 @@
self.tested.add(rev)
return group
- def _pre_filter_rev(self, rev):
- """return True if it seems okay to test a rev, False otherwise"""
+ def _pre_filter_rev_universal(self, rev):
+ """pre filtering that is need in all cases.
+
+ return True if it seems okay to test a rev, False otherwise.
+
+ used by _pre_filter_rev.
+ """
# no need to try a delta against nullrev, this will be done as
# a last resort.
if rev == nullrev:
@@ -757,6 +762,15 @@
# in the revlog
if self.target_rev is not None and rev >= self.target_rev:
return False
+ # no delta for rawtext-changing revs (see "candelta" for why)
+ if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS:
+ return False
+ return True
+
+ def _pre_filter_rev(self, rev):
+ """return True if it seems okay to test a rev, False otherwise"""
+ if not self._pre_filter_rev_universal(rev):
+ return False
deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT
# filter out delta base that will never produce good delta
@@ -774,10 +788,6 @@
):
return False
- # no delta for rawtext-changing revs (see "candelta" for why)
- if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS:
- return False
-
# If we reach here, we are about to build and test a delta.
# The delta building process will compute the chaininfo in all
# case, since that computation is cached, it is fine to access