Patchwork [3,of,3] revlog: add wrapper for key frames compression

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

Comments

Wojciech Lopata - Sept. 27, 2013, 1:07 a.m.
# HG changeset patch
# User Wojciech Lopata <lopek@fb.com>
# Date 1380241907 25200
#      Thu Sep 26 17:31:47 2013 -0700
# Node ID 548e6221e515cec4eaf10c1bb95c5a9774b798a6
# Parent  ccb3533b2c70559344c6f4536752abd8f9d26376
revlog: add wrapper for key frames compression

This will allow revlog subclasses perform some specific transformations in
order to improve compression ratio.

In particular, in case of manifest it would be possible to benefit from 'stem
compression' idea.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -856,7 +856,7 @@ 
         return decompress(self._chunkraw(rev, rev))
 
     def _keyframechunk(self, rev):
-        return decompress(self._chunkraw(rev, rev))
+        return self.decompresskeyframe(self._chunkraw(rev, rev))
 
     def _deltachunks(self, revs):
         '''faster version of [self._deltachunk(rev) for rev in revs]
@@ -1082,6 +1082,16 @@ 
             return ('u', text)
         return ("", bin)
 
+    def compresskeyframe(self, text):
+        """wrapper for key frames compression
+
+        revision format aware subclasses may override this method to perform
+        transformations of key frames to achieve better compression ratio """
+        return self.compress(text)
+
+    def decompresskeyframe(self, bin):
+        return decompress(bin)
+
     def _addrevision(self, node, text, transaction, link, p1, p2,
                      cachedelta, ifh, dfh):
         """internal function to add revisions to the log
@@ -1158,7 +1168,7 @@ 
             textlen = len(text)
         if d is None or dist > textlen * 2:
             text = buildtext()
-            data = self.compress(text)
+            data = self.compresskeyframe(text)
             l = len(data[1]) + len(data[0])
             base = chainbase = curr