changeset 49786:0bda07f34c01 stable

emitrevision: also check the parents in the availability closure One of the point of having a closure is to gather the logic in it. So we gather the logic. The `parents[:]` part is a bit ugly but will be replaced by better code soon anyway.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 28 Nov 2022 15:59:52 +0100
parents fa955e3f6aee
children bb2c663c840f
files mercurial/utils/storageutil.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/utils/storageutil.py	Mon Nov 28 15:48:51 2022 +0100
+++ b/mercurial/utils/storageutil.py	Mon Nov 28 15:59:52 2022 +0100
@@ -390,16 +390,26 @@
 
     # Set of revs available to delta against.
     available = set()
+    parents = []
 
     def is_usable_base(rev):
-        return rev != nullrev and rev in available
+        """Is a delta against this revision usable over the wire"""
+        if rev == nullrev:
+            return False
+        # Base revision was already emitted in this group.
+        if rev in available:
+            return True
+        # Base revision is a parent that hasn't been emitted already.
+        if assumehaveparentrevisions and rev in parents:
+            return True
+        return False
 
     for rev in revs:
         if rev == nullrev:
             continue
 
         node = fnode(rev)
-        p1rev, p2rev = store.parentrevs(rev)
+        parents[:] = p1rev, p2rev = store.parentrevs(rev)
 
         if deltaparentfn:
             deltaparentrev = deltaparentfn(rev)
@@ -421,16 +431,9 @@
         # amounts to effectively copying data from storage and is
         # therefore the fastest.
         elif deltaparentrev != nullrev:
-            # Base revision was already emitted in this group. We can
-            # always safely use the delta.
+            # If the stored delta works, let us use it !
             if is_usable_base(deltaparentrev):
                 baserev = deltaparentrev
-
-            # Base revision is a parent that hasn't been emitted already.
-            # Use it if we can assume the receiver has the parent revision.
-            elif assumehaveparentrevisions and deltaparentrev in (p1rev, p2rev):
-                baserev = deltaparentrev
-
             # No guarantee the receiver has the delta parent. Send delta
             # against last revision (if possible), which in the common case
             # should be similar enough to this revision that the delta is