delta-find: split the delta-chain part of `_pre_filter_rev` in a method
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 04 Jan 2024 15:04:10 +0100
changeset 51340 1ea56b10dd4a
parent 51339 9a1239c362ae
child 51341 176d530f59af
delta-find: split the delta-chain 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.
mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py	Thu Jan 04 14:51:48 2024 +0100
+++ b/mercurial/revlogutils/deltas.py	Thu Jan 04 15:04:10 2024 +0100
@@ -808,11 +808,13 @@
                     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
+    def _pre_filter_rev_delta_chain(self, rev):
+        """pre filtering that is needed in sparse revlog cases
 
+        return True if it seems okay to test a rev, False otherwise.
+
+        used by _pre_filter_rev.
+        """
         deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT
         # filter out delta base that will never produce good delta
         #
@@ -835,7 +837,14 @@
         # if chain already have too much data, skip base
         if deltas_limit < chainsize:
             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
+        if not self._pre_filter_rev_delta_chain(rev):
+            return False
         if self.revlog.delta_config.sparse_revlog:
             if not self._pre_filter_rev_sparse(rev):
                 return False