[Request] [+ ] D12208: revlog: return 0 for the fast_rank of nullrev

pacien (Pacien) phabricator at mercurial-scm.org
Mon Feb 21 17:13:38 UTC 2022


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

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):



To: pacien, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220221/379b2968/attachment.html>


More information about the Mercurial-patches mailing list