[PATCH 1 of 5] revlog: make code in builddelta() slightly easier to read

Gregory Szorc gregory.szorc at gmail.com
Sun Sep 25 16:42:13 EDT 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1472094052 25200
#      Wed Aug 24 20:00:52 2016 -0700
# Node ID 74301e44b7398b9c6e3baf4944d0aa99c5979ac4
# Parent  b19c2679289cc5e9b51eac84b63c304bda0096dc
revlog: make code in builddelta() slightly easier to read

self.compress() is destructured into its components. "l" is renamed
to "deltalen."

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1435,28 +1435,29 @@ class revlog(object):
                     delta = header + t
                 else:
                     if self._inline:
                         fh = ifh
                     else:
                         fh = dfh
                     ptext = self.revision(self.node(rev), _df=fh)
                     delta = mdiff.textdiff(ptext, t)
-            data = self.compress(delta)
-            l = len(data[1]) + len(data[0])
+            header, data = self.compress(delta)
+            deltalen = len(header) + len(data)
             chainbase = self.chainbase(rev)
-            dist = l + offset - self.start(chainbase)
+            dist = deltalen + offset - self.start(chainbase)
             if self._generaldelta:
                 base = rev
             else:
                 base = chainbase
             chainlen, compresseddeltalen = self._chaininfo(rev)
             chainlen += 1
-            compresseddeltalen += l
-            return dist, l, data, base, chainbase, chainlen, compresseddeltalen
+            compresseddeltalen += deltalen
+            return (dist, deltalen, (header, data), base,
+                    chainbase, chainlen, compresseddeltalen)
 
         curr = len(self)
         prev = curr - 1
         offset = self.end(prev)
         delta = None
         p1r, p2r = self.rev(p1), self.rev(p2)
 
         # full versions are inserted when the needed deltas


More information about the Mercurial-devel mailing list