From 453d103fadc444174b142a99c0673e6f541e1a8f Mon Sep 17 00:00:00 2001 From: Pierre-Yves David Date: Tue, 1 Dec 2015 16:06:20 -0800 Subject: [PATCH] addrevision: only use the incoming base if it is a good delta (issue4975) Before this change, the 'lazydeltabase' would blindly build a delta using the base provided by the incoming bundle and try to use it. If that base was far down the revlog, the delta would be seen as "no good" and we would fall back to a full text revision. We now check if the delta is good and fallback to a computing a delta again the tipmost revision otherwise (as we would do without general delta). Later changesets will improve the logic to compute the fallback delta using the general delta logic. --- mercurial/revlog.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mercurial/revlog.py b/mercurial/revlog.py index cac3554e0f..ad8c4d23de 100644 --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1427,7 +1427,12 @@ class revlog(object): if cachedelta and self._generaldelta and self._lazydeltabase: # Assume what we received from the server is a good choice # build delta will reuse the cache - delta = builddelta(cachedelta[0]) + candidatedelta = builddelta(cachedelta[0]) + if self._isgooddelta(candidatedelta, textlen): + delta = candidatedelta + elif prev != candidatedelta[3]: + # Try against prev to hopefully save us a fulltext. + delta = builddelta(prev) elif self._generaldelta: if p2r != nullrev and self._aggressivemergedeltas: delta = builddelta(p1r)