# HG changeset patch # User Pierre-Yves David # Date 2015-12-02 00:06:20 # Node ID 8e7db961535aa88781d60807d8144efb460b9e79 # Parent b481bf14992d50bfa67d6fefe8adb6ad1a4c1c88 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. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- 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)