Patchwork [3,of,4] revlog: make calls to _isgooddelta() consistent

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 5, 2015, 5:57 a.m.
Message ID <fd8f2cd725f35a189e01.1449295060@waste.org>
Download mbox | patch
Permalink /patch/11842/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Dec. 5, 2015, 5:57 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1449278054 28800
#      Fri Dec 04 17:14:14 2015 -0800
# Node ID fd8f2cd725f35a189e01c2d89b19f2ea004276f1
# Parent  1d2f1904bc0a8e49f80e3be627900fd2e7865ffd
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.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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])