diff mercurial/pure/parsers.py @ 47256:2b69555e4875

revlog: introduce a compression mode for sidedata in the revlog index We will use this for compression for the sidedata payload. Differential Revision: https://phab.mercurial-scm.org/D10653
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 21:34:02 +0200
parents 6bfa6c2c5f15
children 07641bafa646
line wrap: on
line diff
--- a/mercurial/pure/parsers.py	Mon May 03 21:13:24 2021 +0200
+++ b/mercurial/pure/parsers.py	Mon May 03 21:34:02 2021 +0200
@@ -66,6 +66,7 @@
         0,
         0,
         revlog_constants.COMP_MODE_INLINE,
+        revlog_constants.COMP_MODE_INLINE,
     )
 
     @util.propertycache
@@ -147,7 +148,12 @@
 
     def _unpack_entry(self, data):
         r = self.index_format.unpack(data)
-        r = r + (0, 0, revlog_constants.COMP_MODE_INLINE)
+        r = r + (
+            0,
+            0,
+            revlog_constants.COMP_MODE_INLINE,
+            revlog_constants.COMP_MODE_INLINE,
+        )
         return r
 
     def pack_header(self, header):
@@ -315,10 +321,19 @@
             self._extra[rev - self._lgt] = new
 
     def _unpack_entry(self, data):
-        return self.index_format.unpack(data)
+        data = self.index_format.unpack(data)
+        entry = data[:10]
+        data_comp = data[10] & 3
+        sidedata_comp = (data[10] & (3 << 2)) >> 2
+        return entry + (data_comp, sidedata_comp)
 
     def _pack_entry(self, entry):
-        return self.index_format.pack(*entry[:11])
+        data = entry[:10]
+        data_comp = entry[10] & 3
+        sidedata_comp = (entry[11] & 3) << 2
+        data += (data_comp | sidedata_comp,)
+
+        return self.index_format.pack(*data)
 
     def entry_binary(self, rev):
         """return the raw binary string representing a revision"""