Mercurial > hg
comparison mercurial/revlog.py @ 39087:f90b333e79cb
revlog: filter out "invalid" delta base candidates
There are bases that we know won't produce a good delta chain. For example, if
the base is already bigger than twice the size of the text we store, we know
the resulting delta chain will never be valid.
We might make the check a bit more powerful and generic in the future, but
this looks a good start.
In particular, empty file (size 0) will never find a good base, so we should
stop spending time trying to find one.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 27 Jul 2018 12:08:10 +0200 |
parents | 64ddad2f26bb |
children | 65d5de1169dd |
comparison
equal
deleted
inserted
replaced
39086:64ddad2f26bb | 39087:f90b333e79cb |
---|---|
748 | 748 |
749 deltalength = self.revlog.length | 749 deltalength = self.revlog.length |
750 deltaparent = self.revlog.deltaparent | 750 deltaparent = self.revlog.deltaparent |
751 | 751 |
752 deltainfo = None | 752 deltainfo = None |
753 deltas_limit = revinfo.textlen * LIMIT_DELTA2TEXT | |
753 for candidaterevs in self._getcandidaterevs(p1, p2, cachedelta): | 754 for candidaterevs in self._getcandidaterevs(p1, p2, cachedelta): |
755 # filter out delta base that will never produce good delta | |
756 candidaterevs = [r for r in candidaterevs | |
757 if self.revlog.length(r) <= deltas_limit] | |
754 nominateddeltas = [] | 758 nominateddeltas = [] |
755 for candidaterev in candidaterevs: | 759 for candidaterev in candidaterevs: |
756 # skip over empty delta (no need to include them in a chain) | 760 # skip over empty delta (no need to include them in a chain) |
757 while candidaterev != nullrev and not deltalength(candidaterev): | 761 while candidaterev != nullrev and not deltalength(candidaterev): |
758 candidaterev = deltaparent(candidaterev) | 762 candidaterev = deltaparent(candidaterev) |