Mercurial > hg
changeset 49670:2fd8750f3722
emitrevision: if we need to compute a delta on the fly, try p1 or p2 first
Falling back to `prev` does not yield any real value on modern storage and
result in pathological changes to be created on the other side. Doing a delta
against a parent will likely be smaller (helping the network) and will be safer
to apply on the client (helping future pulls by Triggering intermediate
snapshop where they will be needed by later deltas).
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 24 Nov 2022 04:04:19 +0100 |
parents | f064b03d061a |
children | 92c65bd0c4d6 |
files | mercurial/utils/storageutil.py |
diffstat | 1 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/utils/storageutil.py Mon Nov 28 16:27:23 2022 +0100 +++ b/mercurial/utils/storageutil.py Thu Nov 24 04:04:19 2022 +0100 @@ -460,14 +460,29 @@ debug_delta_source = "storage" baserev = deltaparentrev else: + if deltaparentrev != nullrev and debug_info is not None: + debug_info['denied-base-not-available'] += 1 # No guarantee the receiver has the delta parent, or Storage has a # fulltext revision. # - # Send delta against last revision (if possible), which in the - # common case should be similar enough to this revision that the - # delta is reasonable. - if deltaparentrev != nullrev and debug_info is not None: - debug_info['denied-base-not-available'] += 1 + # We compute a delta on the fly to send over the wire. + # + # We start with a try against p1, which in the common case should + # be close to this revision content. + # + # note: we could optimize between p1 and p2 in merges cases. + elif is_usable_base(p1rev): + if debug_info is not None: + debug_delta_source = "p1" + baserev = p1rev + # if p1 was not an option, try p2 + elif is_usable_base(p2rev): + if debug_info is not None: + debug_delta_source = "p2" + baserev = p2rev + # Send delta against prev in despair + # + # using the closest available ancestors first might be better? elif prevrev is not None: if debug_info is not None: debug_delta_source = "prev"