# HG changeset patch # User Pierre-Yves David # Date 1669259059 -3600 # Node ID 31b4675ca998d44a41aff51d2b26fcc514d0d7dd # Parent bb2c663c840f6adb621f070994ff0a0d2956fe2a 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). diff -r bb2c663c840f -r 31b4675ca998 mercurial/utils/storageutil.py --- 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 @@ -436,10 +436,21 @@ # 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 prevrev is not None: + # 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. + if is_usable_base(p1rev): + baserev = p1rev + # if p1 was not an option, try p2 + elif is_usable_base(p2rev): + baserev = p2rev + # Send delta against prev in despair + # + # using the closest available ancestors first might be better? + elif prevrev is not None: baserev = prevrev else: baserev = nullrev