changeset 47257:87d057137f82

revlog: apply compression mode while reading sidedata Right now, we only store things as PLAIN, but we are ready for some compression now. Future changeset will start using some. Differential Revision: https://phab.mercurial-scm.org/D10654
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 03 May 2021 22:48:31 +0200
parents 2b69555e4875
children c4dbb7636a12
files mercurial/revlog.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon May 03 21:34:02 2021 +0200
+++ b/mercurial/revlog.py	Mon May 03 22:48:31 2021 +0200
@@ -2061,7 +2061,19 @@
         if sidedata_size == 0:
             return {}
 
-        segment = self._getsegment(sidedata_offset, sidedata_size)
+        comp_segment = self._getsegment(sidedata_offset, sidedata_size)
+        comp = self.index[rev][11]
+        if comp == COMP_MODE_PLAIN:
+            segment = comp_segment
+        elif comp == COMP_MODE_DEFAULT:
+            segment = self._decompressor(comp_segment)
+        elif comp == COMP_MODE_INLINE:
+            segment = self.decompress(comp_segment)
+        else:
+            msg = 'unknown compression mode %d'
+            msg %= comp
+            raise error.RevlogError(msg)
+
         sidedata = sidedatautil.deserialize_sidedata(segment)
         return sidedata