# HG changeset patch # User Paul Morelle # Date 2018-05-14 11:05:14 # Node ID 9bf0bd4d7a2e44be4b15f8e1d51eb6d562e509e8 # Parent 6acf41bb8d40c55073e846b81c7466f4b0d390dc 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 --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -326,12 +326,19 @@ class _deltacomputer(object): # 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