Mercurial > public > mercurial-scm > hg
comparison mercurial/pure/parsers.py @ 48499:52034c42c09d
rank: add a "rank" value to the revlog-entry tuple
The rank of a revision is the size of sub-graph it defines as a head. In other
words, the rank of X is the size of `ancestors(X)` (X included).
This is a property that can help various algorithm and we intend to store it in
changelog-v2. We start with adding this new information to the "entry tuple",
with a default value. We will start to compute and persist the rank later.
Differential Revision: https://phab.mercurial-scm.org/D11936
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 14 Dec 2021 23:56:38 +0100 |
parents | 2c6084f67a86 |
children | c5d6c874766a |
comparison
equal
deleted
inserted
replaced
48498:d5137c00ab17 | 48499:52034c42c09d |
---|---|
582 sha1nodeconstants.nullid, | 582 sha1nodeconstants.nullid, |
583 0, | 583 0, |
584 0, | 584 0, |
585 revlog_constants.COMP_MODE_INLINE, | 585 revlog_constants.COMP_MODE_INLINE, |
586 revlog_constants.COMP_MODE_INLINE, | 586 revlog_constants.COMP_MODE_INLINE, |
587 revlog_constants.RANK_UNKNOWN, | |
587 ) | 588 ) |
588 | 589 |
589 @util.propertycache | 590 @util.propertycache |
590 def entry_size(self): | 591 def entry_size(self): |
591 return self.index_format.size | 592 return self.index_format.size |
669 r = r + ( | 670 r = r + ( |
670 0, | 671 0, |
671 0, | 672 0, |
672 revlog_constants.COMP_MODE_INLINE, | 673 revlog_constants.COMP_MODE_INLINE, |
673 revlog_constants.COMP_MODE_INLINE, | 674 revlog_constants.COMP_MODE_INLINE, |
675 revlog_constants.RANK_UNKNOWN, | |
674 ) | 676 ) |
675 return r | 677 return r |
676 | 678 |
677 def pack_header(self, header): | 679 def pack_header(self, header): |
678 """pack header information as binary""" | 680 """pack header information as binary""" |
851 def _unpack_entry(self, rev, data): | 853 def _unpack_entry(self, rev, data): |
852 data = self.index_format.unpack(data) | 854 data = self.index_format.unpack(data) |
853 entry = data[:10] | 855 entry = data[:10] |
854 data_comp = data[10] & 3 | 856 data_comp = data[10] & 3 |
855 sidedata_comp = (data[10] & (3 << 2)) >> 2 | 857 sidedata_comp = (data[10] & (3 << 2)) >> 2 |
856 return entry + (data_comp, sidedata_comp) | 858 return entry + (data_comp, sidedata_comp, revlog_constants.RANK_UNKNOWN) |
857 | 859 |
858 def _pack_entry(self, rev, entry): | 860 def _pack_entry(self, rev, entry): |
859 data = entry[:10] | 861 data = entry[:10] |
860 data_comp = entry[10] & 3 | 862 data_comp = entry[10] & 3 |
861 sidedata_comp = (entry[11] & 3) << 2 | 863 sidedata_comp = (entry[11] & 3) << 2 |
894 revlog_constants.INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH | 896 revlog_constants.INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH |
895 ], | 897 ], |
896 items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3, | 898 items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3, |
897 (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2) | 899 (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2) |
898 & 3, | 900 & 3, |
901 revlog_constants.RANK_UNKNOWN, | |
899 ) | 902 ) |
900 | 903 |
901 def _pack_entry(self, rev, entry): | 904 def _pack_entry(self, rev, entry): |
902 | 905 |
903 base = entry[revlog_constants.ENTRY_DELTA_BASE] | 906 base = entry[revlog_constants.ENTRY_DELTA_BASE] |