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
--- 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