revlog: make calls to _isgooddelta() consistent
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 04 Dec 2015 17:14:14 -0800
changeset 27250 bff71fe05768
parent 27249 0e5aab543d85
child 27251 d9bfe6289acf
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.
mercurial/revlog.py
--- 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])