mercurial/pure/parsers.py
changeset 47270 25ce16bf724b
parent 47268 9d1a8829f959
child 47394 ac60a1366a49
--- 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