# HG changeset patch # User Pierre-Yves David # Date 1669647592 -3600 # Node ID 0bda07f34c0192a44db1f0f3f22cad620b84e582 # Parent fa955e3f6aee4369f41557b3d2e123709c02ea0c 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. diff -r fa955e3f6aee -r 0bda07f34c01 mercurial/utils/storageutil.py --- 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