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

login
register
mail settings
Submitter Paul Morelle
Date May 14, 2018, 12:11 p.m.
Message ID <12fd4a2e154a679a601b.1526299917@belenos.localdomain>
Download mbox | patch
Permalink /patch/31586/
State Accepted
Headers show

Comments

Paul Morelle - May 14, 2018, 12:11 p.m.
# HG changeset patch
# User Paul Morelle <paul.morelle@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.
Yuya Nishihara - May 21, 2018, 11:55 a.m.
On Mon, 14 May 2018 14:11:57 +0200, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle <paul.morelle@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.

To my knowledge, this looks good to me. It's floating for a week with no
comment, so queued. Thanks.

Patch

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