revlog: suggest other parent when a parent was refused for a delta (issue5481)
authorPaul Morelle <paul.morelle@octobus.net>
Mon, 14 May 2018 13:05:14 +0200
changeset 38102 9bf0bd4d7a2e
parent 38101 6acf41bb8d40
child 38103 a2f83661f721
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.
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon May 14 22:02:44 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