Patchwork [2,of,3] revlog: split _chunk method into _deltachunk and _keyframechunk

login
register
mail settings
Submitter Wojciech Lopata
Date Sept. 27, 2013, 1:07 a.m.
Message ID <ccb3533b2c70559344c6.1380244040@dev1179.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2657/
State Deferred
Headers show

Comments

Wojciech Lopata - Sept. 27, 2013, 1:07 a.m.
# HG changeset patch
# User Wojciech Lopata <lopek@fb.com>
# Date 1380211580 25200
#      Thu Sep 26 09:06:20 2013 -0700
# Node ID ccb3533b2c70559344c6f4536752abd8f9d26376
# Parent  336071e24234a66a052f9260cc93552c6379c8d9
revlog: split _chunk method into _deltachunk and _keyframechunk

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -73,12 +73,12 @@ 
             chain = node
             n += 1
 
-    def _chunk(self, rev):
+    def _deltachunk(self, rev):
         # Warning: in case of bundle, the diff is against what we stored as
         # delta base, not against rev - 1
         # XXX: could use some caching
         if rev <= self.repotiprev:
-            return revlog.revlog._chunk(self, rev)
+            return revlog.revlog._deltachunk(self, rev)
         self.bundle.seek(self.start(rev))
         return self.bundle.read(self.length(rev))
 
@@ -88,7 +88,7 @@ 
             # hot path for bundle
             revb = self.index[rev2][3]
             if revb == rev1:
-                return self._chunk(rev2)
+                return self._deltachunk(rev2)
         elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
             return revlog.revlog.revdiff(self, rev1, rev2)
 
@@ -123,7 +123,7 @@ 
             text = self.baserevision(iterrev)
 
         while chain:
-            delta = self._chunk(chain.pop())
+            delta = self._deltachunk(chain.pop())
             text = mdiff.patches(text, [delta])
 
         self._checkhash(text, node, rev)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -852,11 +852,14 @@ 
         length = end - start
         return self._getchunk(start, length)
 
-    def _chunk(self, rev):
+    def _deltachunk(self, rev):
         return decompress(self._chunkraw(rev, rev))
 
-    def _chunks(self, revs):
-        '''faster version of [self._chunk(rev) for rev in revs]
+    def _keyframechunk(self, rev):
+        return decompress(self._chunkraw(rev, rev))
+
+    def _deltachunks(self, revs):
+        '''faster version of [self._deltachunk(rev) for rev in revs]
 
         Assumes that revs is in ascending order.'''
         if not revs:
@@ -899,7 +902,7 @@ 
     def revdiff(self, rev1, rev2):
         """return or calculate a delta between two revisions"""
         if rev1 != nullrev and self.deltaparent(rev2) == rev1:
-            return str(self._chunk(rev2))
+            return str(self._deltachunk(rev2))
 
         return mdiff.textdiff(self.revision(rev1),
                               self.revision(rev2))
@@ -946,21 +949,18 @@ 
             else:
                 iterrev -= 1
             e = index[iterrev]
+        chain.reverse()
 
         if iterrev == cachedrev:
             # cache hit
             text = self._cache[2]
-        else:
-            chain.append(iterrev)
-        chain.reverse()
 
         # drop cache to save memory
         self._cache = None
 
-        bins = self._chunks(chain)
+        bins = self._deltachunks(chain)
         if text is None:
-            text = str(bins[0])
-            bins = bins[1:]
+            text = str(self._keyframechunk(iterrev))
 
         text = mdiff.patches(text, bins)