comparison mercurial/revlog.py @ 48851:d739cd69bb6a

revlog: return 0 for the fast_rank of nullrev By convention, the rank of the null revision is 0. This particular revision is never "physically" stored in the changelog, so it is a special case. For consistency, the value `None` is still being returned for revlogs which do not store the fast_rank property for any revision. Differential Revision: https://phab.mercurial-scm.org/D12208
author pacien <pacien.trangirard@pacien.net>
date Mon, 21 Feb 2022 15:53:03 +0100
parents 1bb62821f080
children 6ea9ead59cf8
comparison
equal deleted inserted replaced
48850:656196c1d442 48851:d739cd69bb6a
867 This method returns the rank retrieved from the revlog in constant 867 This method returns the rank retrieved from the revlog in constant
868 time. It makes no attempt at computing unknown values for versions of 868 time. It makes no attempt at computing unknown values for versions of
869 the revlog which do not persist the rank. 869 the revlog which do not persist the rank.
870 """ 870 """
871 rank = self.index[rev][ENTRY_RANK] 871 rank = self.index[rev][ENTRY_RANK]
872 if rank == RANK_UNKNOWN: 872 if self._format_version != CHANGELOGV2 or rank == RANK_UNKNOWN:
873 return None 873 return None
874 if rev == nullrev:
875 return 0 # convention
874 return rank 876 return rank
875 877
876 def chainbase(self, rev): 878 def chainbase(self, rev):
877 base = self._chainbasecache.get(rev) 879 base = self._chainbasecache.get(rev)
878 if base is not None: 880 if base is not None: