Patchwork D12208: revlog: return 0 for the fast_rank of nullrev

login
register
mail settings
Submitter phabricator
Date Feb. 21, 2022, 5:13 p.m.
Message ID <differential-rev-PHID-DREV-s2lghgmekdphbpq4tiww-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50547/
State New
Headers show

Comments

phabricator - Feb. 21, 2022, 5:13 p.m.
pacien created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12208

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: pacien, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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):