Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatekw.py @ 48765:d5121df04808
rank: add context and template keyword
This makes the stored rank property accessible, to be expanded and printed.
Differential Revision: https://phab.mercurial-scm.org/D12140
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 28 Jan 2022 11:35:41 +0100 |
parents | 7531cc34713c |
children | 6000f5b25c9b |
line wrap: on
line diff
--- a/mercurial/templatekw.py Fri Jan 28 11:33:01 2022 +0100 +++ b/mercurial/templatekw.py Fri Jan 28 11:35:41 2022 +0100 @@ -304,6 +304,21 @@ ) +@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')