Comments
Patch
@@ -40,11 +40,13 @@
COMP_MODE_DEFAULT,
COMP_MODE_INLINE,
COMP_MODE_PLAIN,
+ ENTRY_RANK,
FEATURES_BY_VERSION,
FLAG_GENERALDELTA,
FLAG_INLINE_DATA,
INDEX_HEADER,
KIND_CHANGELOG,
+ RANK_UNKNOWN,
REVLOGV0,
REVLOGV1,
REVLOGV1_FLAGS,
@@ -872,6 +874,20 @@
return len(self.revision(rev, raw=False))
+ def fast_rank(self, rev):
+ """The "rank" of the revision if available, None otherwise
+
+ The rank of a revision is the size of sub-graph it defines as a head.
+ In other words, the rank og X i sthe size of `ancestors(X)` (X
+ included).
+
+ Some variant of revlog persist this value and make it available.
+ """
+ rank = self.index[rev][ENTRY_RANK]
+ if rank == RANK_UNKNOWN:
+ return None
+ return rank
+
def chainbase(self, rev):
base = self._chainbasecache.get(rev)
if base is not None:
@@ -2472,6 +2488,11 @@
# than ones we manually add.
sidedata_offset = 0
+ # maybe the index.append should compute it when applicable instead
+ rank = RANK_UNKNOWN
+ if self._format_version == CHANGELOGV2:
+ rank = len(list(self.ancestors([p1r, p2r], inclusive=True))) + 1
+
e = revlogutils.entry(
flags=flags,
data_offset=offset,
@@ -2486,6 +2507,7 @@
sidedata_offset=sidedata_offset,
sidedata_compressed_length=len(serialized_sidedata),
sidedata_compression_mode=sidedata_compression_mode,
+ rank=rank,
)
self.index.append(e)