changeset 51353:5cc04a6da19d

delta-find: move the emotion of parents in a dedicated method After splitting the filtering, and with the `_candidate_groups` layer removed, we can start splitting the group generation too. This helps to organize this code and make it easier to modifying the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 Nov 2023 21:51:43 +0100
parents 7083b33a2699
children 94fe4474b053
files mercurial/revlogutils/deltas.py
diffstat 1 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py	Sun Jan 07 03:08:46 2024 +0100
+++ b/mercurial/revlogutils/deltas.py	Thu Nov 23 21:51:43 2023 +0100
@@ -1055,6 +1055,25 @@
 
         return True
 
+    def _iter_parents(self):
+        # exclude already lazy tested base if any
+        parents = [p for p in (self.p1, self.p2) if p != nullrev]
+
+        self.current_stage = _STAGE_PARENTS
+        if (
+            not self.revlog.delta_config.delta_both_parents
+            and len(parents) == 2
+        ):
+            parents.sort()
+            # To minimize the chance of having to build a fulltext,
+            # pick first whichever parent is closest to us (max rev)
+            yield (parents[1],)
+            # then the other one (min rev) if the first did not fit
+            yield (parents[0],)
+        elif len(parents) > 0:
+            # Test all parents (1 or 2), and keep the best candidate
+            yield parents
+
     def _refined_groups(self):
         good = None
         groups = self._raw_groups()
@@ -1107,28 +1126,12 @@
 
         The group order aims at providing fast or small candidates first.
         """
+        yield from self._iter_parents()
         sparse = self.revlog.delta_config.sparse_revlog
         prev = self.target_rev - 1
         deltachain = lambda rev: self.revlog._deltachain(rev)[0]
 
-        # exclude already lazy tested base if any
         parents = [p for p in (self.p1, self.p2) if p != nullrev]
-
-        self.current_stage = _STAGE_PARENTS
-        if (
-            not self.revlog.delta_config.delta_both_parents
-            and len(parents) == 2
-        ):
-            parents.sort()
-            # To minimize the chance of having to build a fulltext,
-            # pick first whichever parent is closest to us (max rev)
-            yield (parents[1],)
-            # then the other one (min rev) if the first did not fit
-            yield (parents[0],)
-        elif len(parents) > 0:
-            # Test all parents (1 or 2), and keep the best candidate
-            yield parents
-
         if sparse and parents:
             self.current_stage = _STAGE_SNAPSHOT
             # See if we can use an existing snapshot in the parent chains to