Patchwork D10654: revlog: apply compression mode while reading sidedata

login
register
mail settings
Submitter phabricator
Date May 4, 2021, 2:20 p.m.
Message ID <differential-rev-PHID-DREV-tnneqpeecg6nld6pubjd-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48972/
State Superseded
Headers show

Comments

phabricator - May 4, 2021, 2:20 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Right now, we only store things as PLAIN, but we are ready for some compression
  now. Future changeset will start using some.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10654

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2060,7 +2060,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