# HG changeset patch # User Boris Feld # Date 2018-09-10 06:31:41 # Node ID a911932d500311eb6cbe8ec8cbab435547cebfa0 # Parent bdb41eaa8b597713983ac0b293ce552a1d516da9 revlog: reuse cached delta for identical base revision (issue5975) Since 8f83a953dddf, we skip over empty deltas when choosing a delta base. Such delta happens when two distinct revisions have the same content. The remote might be sending a delta against such revision within the bundle. In that case, the delta base is no longer considered, but the cached one could still, be used with the equivalent revision. Not reusing the delta from the bundle can have a significant performance impact, so we now make sure with doing so when possible. diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py +++ b/mercurial/revlogutils/deltas.py @@ -832,9 +832,18 @@ class deltacomputer(object): def _builddeltainfo(self, revinfo, base, fh): # can we use the cached delta? - if revinfo.cachedelta and revinfo.cachedelta[0] == base: - delta = revinfo.cachedelta[1] - else: + delta = None + if revinfo.cachedelta: + cachebase, cachediff = revinfo.cachedelta + #check if the diff still apply + currentbase = cachebase + while (currentbase != nullrev + and currentbase != base + and self.revlog.length(currentbase) == 0): + currentbase = self.revlog.deltaparent(currentbase) + if currentbase == base: + delta = revinfo.cachedelta[1] + if delta is None: delta = self._builddeltadiff(base, revinfo, fh) revlog = self.revlog header, data = revlog.compress(delta)