diff mercurial/pure/parsers.py @ 47270:25ce16bf724b

changelogv2: use a dedicated on disk format for changelogv2 We drop two unused entry. This is mostly a proof of concept before starting to actually rework the format. Differential Revision: https://phab.mercurial-scm.org/D10667
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 04 May 2021 11:20:10 +0200
parents 9d1a8829f959
children ac60a1366a49
line wrap: on
line diff
--- a/mercurial/pure/parsers.py	Tue May 04 14:18:06 2021 +0200
+++ b/mercurial/pure/parsers.py	Tue May 04 11:20:10 2021 +0200
@@ -295,6 +295,10 @@
     return cls(data, inline), (0, data)
 
 
+def parse_index_cl_v2(data):
+    return IndexChangelogV2(data), None
+
+
 class IndexObject2(IndexObject):
     index_format = revlog_constants.INDEX_ENTRY_V2
 
@@ -355,6 +359,26 @@
         raise error.ProgrammingError(msg)
 
 
+class IndexChangelogV2(IndexObject2):
+    index_format = revlog_constants.INDEX_ENTRY_CL_V2
+
+    def _unpack_entry(self, rev, data, r=True):
+        items = self.index_format.unpack(data)
+        entry = items[:3] + (rev, rev) + items[3:8]
+        data_comp = items[8] & 3
+        sidedata_comp = (items[8] >> 2) & 3
+        return entry + (data_comp, sidedata_comp)
+
+    def _pack_entry(self, rev, entry):
+        assert entry[3] == rev, entry[3]
+        assert entry[4] == rev, entry[4]
+        data = entry[:3] + entry[5:10]
+        data_comp = entry[10] & 3
+        sidedata_comp = (entry[11] & 3) << 2
+        data += (data_comp | sidedata_comp,)
+        return self.index_format.pack(*data)
+
+
 def parse_index_devel_nodemap(data, inline):
     """like parse_index2, but alway return a PersistentNodeMapIndexObject"""
     return PersistentNodeMapIndexObject(data), None