diff -r 562cfc99e611 -r 4dc5b51f38fe mercurial/revlog.py --- a/mercurial/revlog.py Sun Aug 30 13:34:30 2015 -0700 +++ b/mercurial/revlog.py Sun Aug 30 13:58:11 2015 -0700 @@ -1343,11 +1343,14 @@ # should we try to build a delta? if prev != nullrev: if self._generaldelta: - if p1r >= basecache[1]: - d = builddelta(p1r) - elif p2r >= basecache[1]: - d = builddelta(p2r) - else: + # Pick whichever parent is closer to us (to minimize the + # chance of having to build a fulltext). Since + # nullrev == -1, any non-merge commit will always pick p1r. + drev = p2r if p2r > p1r else p1r + d = builddelta(drev) + # If the chosen delta will result in us making a full text, + # give it one last try against prev. + if drev != prev and not self._isgooddelta(d, textlen): d = builddelta(prev) else: d = builddelta(prev)