revlog: make calls to _isgooddelta() consistent

We always want to call _isgooddelta() before accepting a delta. We
mostly call the function right after building the delta, but not
always. Instead, we have an extra call at the end of the big code
block. Let's make it consistent, so we call _isgooddelta() right after
builddelta() and exactly once per delta. That also lets us rely on
"delta is None" to mean we didn't find a good delta.
This commit is contained in:
Martin von Zweigbergk 2015-12-04 17:14:14 -08:00
parent af588ff953
commit d9cd156585

View File

@ -1450,11 +1450,12 @@ class revlog(object):
if delta is None and prev not in tested:
# other approach failed try against prev to hopefully save us a
# fulltext.
delta = builddelta(prev)
candidatedelta = builddelta(prev)
if self._isgooddelta(candidatedelta, textlen):
delta = candidatedelta
if delta is not None:
dist, l, data, base, chainbase, chainlen, compresseddeltalen = delta
if not self._isgooddelta(delta, textlen):
else:
text = buildtext()
data = self.compress(text)
l = len(data[1]) + len(data[0])