Patchwork [2,of,4] revlog: move textlen calculation to be above delta chooser

login
register
mail settings
Submitter Durham Goode
Date Aug. 30, 2015, 10:09 p.m.
Message ID <a97c5320ea8b628ec619.1440972593@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10329/
State Accepted
Headers show

Comments

Durham Goode - Aug. 30, 2015, 10:09 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1440966870 25200
#      Sun Aug 30 13:34:30 2015 -0700
# Node ID a97c5320ea8b628ec619b0a5100507fe3ad585ed
# Parent  cae419eb6fc8bf5263727ab030c5b8e2eca0aa6d
revlog: move textlen calculation to be above delta chooser

This moves the textlen calculation to be above the delta chooser. Since textlen
is needed for calling isgooddelta, we need it above the delta chooser so future
patches can call isgooddelta.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1332,6 +1332,14 @@  class revlog(object):
         basecache = self._basecache
         p1r, p2r = self.rev(p1), self.rev(p2)
 
+        # full versions are inserted when the needed deltas
+        # become comparable to the uncompressed text
+        if text is None:
+            textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]),
+                                        cachedelta[1])
+        else:
+            textlen = len(text)
+
         # should we try to build a delta?
         if prev != nullrev:
             if self._generaldelta:
@@ -1345,14 +1353,6 @@  class revlog(object):
                 d = builddelta(prev)
             dist, l, data, base, chainbase, chainlen, compresseddeltalen = d
 
-        # full versions are inserted when the needed deltas
-        # become comparable to the uncompressed text
-        if text is None:
-            textlen = mdiff.patchedsize(self.rawsize(cachedelta[0]),
-                                        cachedelta[1])
-        else:
-            textlen = len(text)
-
         if not self._isgooddelta(d, textlen):
             text = buildtext()
             data = self.compress(text)