Mercurial > hg
comparison mercurial/templatekw.py @ 39587:918944f53aac
templatekw: add {size} keyword as an example of fctx-based keyword
I'll add {status}, and I think some lfs keywords can be migrated to this.
I'm not certain how many fctx-based keywords will be introduced into the
global space, but if there are a couple more, we'll probably need to sort
them out to the "File Keywords" section in the templater help. Until then,
fctx keywords are hidden as experimental.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 29 Jul 2018 21:28:51 +0900 |
parents | 3cd977d5a16b |
children | 164827563426 |
comparison
equal
deleted
inserted
replaced
39586:b1239aeef4d9 | 39587:918944f53aac |
---|---|
580 def showreporoot(context, mapping): | 580 def showreporoot(context, mapping): |
581 """String. The root directory of the current repository.""" | 581 """String. The root directory of the current repository.""" |
582 repo = context.resource(mapping, 'repo') | 582 repo = context.resource(mapping, 'repo') |
583 return repo.root | 583 return repo.root |
584 | 584 |
585 @templatekeyword('size', requires={'fctx'}) | |
586 def showsize(context, mapping): | |
587 """Integer. Size of the current file in bytes. (EXPERIMENTAL)""" | |
588 fctx = context.resource(mapping, 'fctx') | |
589 return fctx.size() | |
590 | |
585 @templatekeyword("successorssets", requires={'repo', 'ctx'}) | 591 @templatekeyword("successorssets", requires={'repo', 'ctx'}) |
586 def showsuccessorssets(context, mapping): | 592 def showsuccessorssets(context, mapping): |
587 """Returns a string of sets of successors for a changectx. Format used | 593 """Returns a string of sets of successors for a changectx. Format used |
588 is: [ctx1, ctx2], [ctx3] if ctx has been splitted into ctx1 and ctx2 | 594 is: [ctx1, ctx2], [ctx3] if ctx has been splitted into ctx1 and ctx2 |
589 while also diverged into ctx3. (EXPERIMENTAL)""" | 595 while also diverged into ctx3. (EXPERIMENTAL)""" |