[PATCH V2] revlog: suggest other parent when a parent was refused for a delta (issue5481)

Paul Morelle paul.morelle at octobus.net
Mon May 14 12:11:57 UTC 2018


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1526295914 -7200
#      Mon May 14 13:05:14 2018 +0200
# Node ID 12fd4a2e154a679a601b8facbb5f15956d427e9e
# Parent  8ba0344f9fb145f5b9b909f1211defc9e0793f68
# EXP-Topic fallback-to-other-parent
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 12fd4a2e154a
revlog: suggest other parent when a parent was refused for a delta (issue5481)

Without aggressivemergedeltas, ensure that when we decline the closest parent
(by revision number), the other parent is examined too.

diff -r 8ba0344f9fb1 -r 12fd4a2e154a mercurial/revlog.py
--- a/mercurial/revlog.py	Fri May 11 22:07:43 2018 -0400
+++ b/mercurial/revlog.py	Mon May 14 13:05:14 2018 +0200
@@ -326,12 +326,19 @@
                 # exclude already lazy tested base if any
                 parents = [p for p in (p1r, p2r)
                            if p != nullrev and p not in tested]
-                if parents and not revlog._aggressivemergedeltas:
-                    # Pick whichever parent is closer to us (to minimize the
-                    # chance of having to build a fulltext).
-                    parents = [max(parents)]
-                tested.update(parents)
-                yield parents
+
+                if not revlog._aggressivemergedeltas and len(parents) == 2:
+                    parents.sort()
+                    # To minimize the chance of having to build a fulltext,
+                    # pick first whichever parent is closest to us (max rev)
+                    yield (parents[1],)
+                    # then the other one (min rev) if the first did not fit
+                    yield (parents[0],)
+                    tested.update(parents)
+                elif len(parents) > 0:
+                    # Test all parents (1 or 2), and keep the best candidate
+                    yield parents
+                    tested.update(parents)
 
             if prev not in tested:
                 # other approach failed try against prev to hopefully save us a


More information about the Mercurial-devel mailing list