[Updated] D12140: rank: add context and template keyword
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Tue Feb 15 14:49:38 UTC 2022
Closed by commit rHGd5121df04808: rank: add context and template keyword (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12140?vs=32168&id=32201
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12140/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12140
AFFECTED FILES
mercurial/context.py
mercurial/templatekw.py
CHANGE DETAILS
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -304,6 +304,21 @@
)
+ at templatekeyword(b'_fast_rank', requires={b'ctx'})
+def fast_rank(context, mapping):
+ """the rank of a changeset if cached
+
+ The rank of a revision is the size of the sub-graph it defines as a head.
+ Equivalently, the rank of a revision `r` is the size of the set
+ `ancestors(r)`, `r` included.
+ """
+ ctx = context.resource(mapping, b'ctx')
+ rank = ctx.fast_rank()
+ if rank is None:
+ return None
+ return b"%d" % rank
+
+
def _getfilestatus(context, mapping, listall=False):
ctx = context.resource(mapping, b'ctx')
revcache = context.resource(mapping, b'revcache')
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -684,6 +684,14 @@
"""Return a list of byte bookmark names."""
return self._repo.nodebookmarks(self._node)
+ def fast_rank(self):
+ repo = self._repo
+ if self._maybe_filtered:
+ cl = repo.changelog
+ else:
+ cl = repo.unfiltered().changelog
+ return cl.fast_rank(self._rev)
+
def phase(self):
return self._repo._phasecache.phase(self._repo, self._rev)
To: pacien, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220215/6093f420/attachment-0002.html>
More information about the Mercurial-patches
mailing list