Mercurial > hg-stable
changeset 49782:383c79f8e5a7
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 | 191f5057ec45 |
children | f064b03d061a |
files | mercurial/utils/storageutil.py |
diffstat | 1 files changed, 13 insertions(+), 11 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 @@ -395,9 +395,19 @@ # 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: @@ -408,7 +418,7 @@ debug_info['revision-total'] += 1 node = fnode(rev) - p1rev, p2rev = store.parentrevs(rev) + parents[:] = p1rev, p2rev = store.parentrevs(rev) if debug_info is not None: if p1rev != p2rev and p1rev != nullrev and p2rev != nullrev: @@ -446,19 +456,11 @@ # 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): if debug_info is not None: debug_delta_source = "storage" 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): - if debug_info is not None: - debug_delta_source = "storage" - 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