comparison mercurial/revlogutils/deltas.py @ 39595:a911932d5003

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.
author Boris Feld <boris.feld@octobus.net>
date Mon, 10 Sep 2018 08:31:41 +0200
parents bdb41eaa8b59
children 2cd93a8d4bde
comparison
equal deleted inserted replaced
39594:bdb41eaa8b59 39595:a911932d5003
830 830
831 return delta 831 return delta
832 832
833 def _builddeltainfo(self, revinfo, base, fh): 833 def _builddeltainfo(self, revinfo, base, fh):
834 # can we use the cached delta? 834 # can we use the cached delta?
835 if revinfo.cachedelta and revinfo.cachedelta[0] == base: 835 delta = None
836 delta = revinfo.cachedelta[1] 836 if revinfo.cachedelta:
837 else: 837 cachebase, cachediff = revinfo.cachedelta
838 #check if the diff still apply
839 currentbase = cachebase
840 while (currentbase != nullrev
841 and currentbase != base
842 and self.revlog.length(currentbase) == 0):
843 currentbase = self.revlog.deltaparent(currentbase)
844 if currentbase == base:
845 delta = revinfo.cachedelta[1]
846 if delta is None:
838 delta = self._builddeltadiff(base, revinfo, fh) 847 delta = self._builddeltadiff(base, revinfo, fh)
839 revlog = self.revlog 848 revlog = self.revlog
840 header, data = revlog.compress(delta) 849 header, data = revlog.compress(delta)
841 deltalen = len(header) + len(data) 850 deltalen = len(header) + len(data)
842 chainbase = revlog.chainbase(base) 851 chainbase = revlog.chainbase(base)