diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1357,10 +1357,10 @@ coreconfigitem( ) # Experimental TODOs: # -# * Same as for evlogv2 (but for the reduction of the number of files) +# * Same as for revlogv2 (but for the reduction of the number of files) +# * Actually computing the rank of changesets # * Improvement to investigate # - storing .hgtags fnode -# - storing `rank` of changesets # - storing branch related identifier coreconfigitem( diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -880,6 +880,12 @@ class IndexObject2(IndexObject): class IndexChangelogV2(IndexObject2): index_format = revlog_constants.INDEX_ENTRY_CL_V2 + null_item = ( + IndexObject2.null_item[: revlog_constants.ENTRY_RANK] + + (0,) # rank of null is 0 + + IndexObject2.null_item[revlog_constants.ENTRY_RANK :] + ) + def _unpack_entry(self, rev, data, r=True): items = self.index_format.unpack(data) return ( @@ -898,7 +904,7 @@ class IndexChangelogV2(IndexObject2): items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3, (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2) & 3, - revlog_constants.RANK_UNKNOWN, + items[revlog_constants.INDEX_ENTRY_V2_IDX_RANK], ) def _pack_entry(self, rev, entry): @@ -919,6 +925,7 @@ class IndexChangelogV2(IndexObject2): entry[revlog_constants.ENTRY_DATA_COMPRESSION_MODE] & 3 | (entry[revlog_constants.ENTRY_SIDEDATA_COMPRESSION_MODE] & 3) << 2, + entry[revlog_constants.ENTRY_RANK], ) 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 @@ -192,8 +192,9 @@ assert INDEX_ENTRY_V2.size == 32 * 3, IN # 8 bytes: sidedata offset # 4 bytes: sidedata compressed length # 1 bytes: compression mode (2 lower bit are data_compression_mode) -# 27 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page) -INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiB27x") +# 4 bytes: changeset rank (i.e. `len(::REV)`) +# 23 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page) +INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiBi23x") assert INDEX_ENTRY_CL_V2.size == 32 * 3, INDEX_ENTRY_CL_V2.size INDEX_ENTRY_V2_IDX_OFFSET = 0 INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH = 1 @@ -204,6 +205,7 @@ 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 +INDEX_ENTRY_V2_IDX_RANK = 9 # revlog index flags