comparison mercurial/templatekw.py @ 38948:390287321b4b

templatekw: copy {author} to {user} and document {author} as an alias In other places including "log -Tjson" and revset, "user" is the canonical name. Let's standardize it. This is a part of the name unification of the Generic Templating Plan. https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Dictionary
author Yuya Nishihara <yuya@tcha.org>
date Tue, 24 Jul 2018 22:13:21 +0900
parents 87a581d1391c
children 83f8f7b9fa60
comparison
equal deleted inserted replaced
38947:f9a98075a37e 38948:390287321b4b
166 keywords = {} 166 keywords = {}
167 templatekeyword = registrar.templatekeyword(keywords) 167 templatekeyword = registrar.templatekeyword(keywords)
168 168
169 @templatekeyword('author', requires={'ctx'}) 169 @templatekeyword('author', requires={'ctx'})
170 def showauthor(context, mapping): 170 def showauthor(context, mapping):
171 """String. The unmodified author of the changeset.""" 171 """Alias for ``{user}``"""
172 ctx = context.resource(mapping, 'ctx') 172 return showuser(context, mapping)
173 return ctx.user()
174 173
175 @templatekeyword('bisect', requires={'repo', 'ctx'}) 174 @templatekeyword('bisect', requires={'repo', 'ctx'})
176 def showbisect(context, mapping): 175 def showbisect(context, mapping):
177 """String. The changeset bisection status.""" 176 """String. The changeset bisection status."""
178 repo = context.resource(mapping, 'repo') 177 repo = context.resource(mapping, 'repo')
754 @templatekeyword('termwidth', requires={'ui'}) 753 @templatekeyword('termwidth', requires={'ui'})
755 def showtermwidth(context, mapping): 754 def showtermwidth(context, mapping):
756 """Integer. The width of the current terminal.""" 755 """Integer. The width of the current terminal."""
757 ui = context.resource(mapping, 'ui') 756 ui = context.resource(mapping, 'ui')
758 return ui.termwidth() 757 return ui.termwidth()
758
759 @templatekeyword('user', requires={'ctx'})
760 def showuser(context, mapping):
761 """String. The unmodified author of the changeset."""
762 ctx = context.resource(mapping, 'ctx')
763 return ctx.user()
759 764
760 @templatekeyword('instabilities', requires={'ctx'}) 765 @templatekeyword('instabilities', requires={'ctx'})
761 def showinstabilities(context, mapping): 766 def showinstabilities(context, mapping):
762 """List of strings. Evolution instabilities affecting the changeset. 767 """List of strings. Evolution instabilities affecting the changeset.
763 (EXPERIMENTAL) 768 (EXPERIMENTAL)