##// END OF EJS Templates
rank: naive rank property computation and retrieval...
marmoute -
r49606:2e949ede default
parent child Browse files
Show More
@@ -40,11 +40,13 b' from .revlogutils.constants import ('
40 COMP_MODE_DEFAULT,
40 COMP_MODE_DEFAULT,
41 COMP_MODE_INLINE,
41 COMP_MODE_INLINE,
42 COMP_MODE_PLAIN,
42 COMP_MODE_PLAIN,
43 ENTRY_RANK,
43 FEATURES_BY_VERSION,
44 FEATURES_BY_VERSION,
44 FLAG_GENERALDELTA,
45 FLAG_GENERALDELTA,
45 FLAG_INLINE_DATA,
46 FLAG_INLINE_DATA,
46 INDEX_HEADER,
47 INDEX_HEADER,
47 KIND_CHANGELOG,
48 KIND_CHANGELOG,
49 RANK_UNKNOWN,
48 REVLOGV0,
50 REVLOGV0,
49 REVLOGV1,
51 REVLOGV1,
50 REVLOGV1_FLAGS,
52 REVLOGV1_FLAGS,
@@ -857,6 +859,22 b' class revlog(object):'
857
859
858 return len(self.revision(rev))
860 return len(self.revision(rev))
859
861
862 def fast_rank(self, rev):
863 """Return the rank of a revision if already known, or None otherwise.
864
865 The rank of a revision is the size of the sub-graph it defines as a
866 head. Equivalently, the rank of a revision `r` is the size of the set
867 `ancestors(r)`, `r` included.
868
869 This method returns the rank retrieved from the revlog in constant
870 time. It makes no attempt at computing unknown values for versions of
871 the revlog which do not persist the rank.
872 """
873 rank = self.index[rev][ENTRY_RANK]
874 if rank == RANK_UNKNOWN:
875 return None
876 return rank
877
860 def chainbase(self, rev):
878 def chainbase(self, rev):
861 base = self._chainbasecache.get(rev)
879 base = self._chainbasecache.get(rev)
862 if base is not None:
880 if base is not None:
@@ -2444,6 +2462,10 b' class revlog(object):'
2444 # than ones we manually add.
2462 # than ones we manually add.
2445 sidedata_offset = 0
2463 sidedata_offset = 0
2446
2464
2465 rank = RANK_UNKNOWN
2466 if self._format_version == CHANGELOGV2:
2467 rank = len(list(self.ancestors([p1r, p2r], inclusive=True))) + 1
2468
2447 e = revlogutils.entry(
2469 e = revlogutils.entry(
2448 flags=flags,
2470 flags=flags,
2449 data_offset=offset,
2471 data_offset=offset,
@@ -2458,6 +2480,7 b' class revlog(object):'
2458 sidedata_offset=sidedata_offset,
2480 sidedata_offset=sidedata_offset,
2459 sidedata_compressed_length=len(serialized_sidedata),
2481 sidedata_compressed_length=len(serialized_sidedata),
2460 sidedata_compression_mode=sidedata_compression_mode,
2482 sidedata_compression_mode=sidedata_compression_mode,
2483 rank=rank,
2461 )
2484 )
2462
2485
2463 self.index.append(e)
2486 self.index.append(e)
General Comments 0
You need to be logged in to leave comments. Login now