revlog: return 0 for the fast_rank of nullrev
authorpacien <pacien.trangirard@pacien.net>
Mon, 21 Feb 2022 15:53:03 +0100
changeset 48851 d739cd69bb6a
parent 48850 656196c1d442
child 48852 e633e660158f
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
mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Mar 02 18:42:00 2022 -0800
+++ b/mercurial/revlog.py	Mon Feb 21 15:53:03 2022 +0100
@@ -869,8 +869,10 @@
         the revlog which do not persist the rank.
         """
         rank = self.index[rev][ENTRY_RANK]
-        if rank == RANK_UNKNOWN:
+        if self._format_version != CHANGELOGV2 or rank == RANK_UNKNOWN:
             return None
+        if rev == nullrev:
+            return 0  # convention
         return rank
 
     def chainbase(self, rev):