changeset 27250:bff71fe05768

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 04 Dec 2015 17:14:14 -0800
parents 0e5aab543d85
children d9bfe6289acf
files mercurial/revlog.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Dec 04 16:45:06 2015 -0800
+++ b/mercurial/revlog.py	Fri Dec 04 17:14:14 2015 -0800
@@ -1450,11 +1450,12 @@
             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])