diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -880,18 +880,43 @@ class IndexChangelogV2(IndexObject2): 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) + return ( + items[revlog_constants.INDEX_ENTRY_V2_IDX_OFFSET], + items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH], + items[revlog_constants.INDEX_ENTRY_V2_IDX_UNCOMPRESSED_LENGTH], + rev, + rev, + items[revlog_constants.INDEX_ENTRY_V2_IDX_PARENT_1], + items[revlog_constants.INDEX_ENTRY_V2_IDX_PARENT_2], + items[revlog_constants.INDEX_ENTRY_V2_IDX_NODEID], + items[revlog_constants.INDEX_ENTRY_V2_IDX_SIDEDATA_OFFSET], + items[ + revlog_constants.INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH + ], + items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3, + (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2) + & 3, + ) 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,) + + base = entry[revlog_constants.ENTRY_DELTA_BASE] + link_rev = entry[revlog_constants.ENTRY_LINK_REV] + assert base == rev, (base, rev) + assert link_rev == rev, (link_rev, rev) + data = ( + entry[revlog_constants.ENTRY_DATA_OFFSET], + entry[revlog_constants.ENTRY_DATA_COMPRESSED_LENGTH], + entry[revlog_constants.ENTRY_DATA_UNCOMPRESSED_LENGTH], + entry[revlog_constants.ENTRY_PARENT_1], + entry[revlog_constants.ENTRY_PARENT_2], + entry[revlog_constants.ENTRY_NODE_ID], + entry[revlog_constants.ENTRY_SIDEDATA_OFFSET], + entry[revlog_constants.ENTRY_SIDEDATA_COMPRESSED_LENGTH], + entry[revlog_constants.ENTRY_DATA_COMPRESSION_MODE] & 3 + | (entry[revlog_constants.ENTRY_SIDEDATA_COMPRESSION_MODE] & 3) + << 2, + ) return self.index_format.pack(*data) diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py --- a/mercurial/revlogutils/constants.py +++ b/mercurial/revlogutils/constants.py @@ -184,6 +184,15 @@ assert INDEX_ENTRY_V2.size == 32 * 3, IN # 27 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page) INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiB27x") assert INDEX_ENTRY_CL_V2.size == 32 * 3, INDEX_ENTRY_V2.size +INDEX_ENTRY_V2_IDX_OFFSET = 0 +INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH = 1 +INDEX_ENTRY_V2_IDX_UNCOMPRESSED_LENGTH = 2 +INDEX_ENTRY_V2_IDX_PARENT_1 = 3 +INDEX_ENTRY_V2_IDX_PARENT_2 = 4 +INDEX_ENTRY_V2_IDX_NODEID = 5 +INDEX_ENTRY_V2_IDX_SIDEDATA_OFFSET = 6 +INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH = 7 +INDEX_ENTRY_V2_IDX_COMPRESSION_MODE = 8 # revlog index flags