Mercurial > hg-stable
changeset 38986: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 | f9a98075a37e |
children | b0c591950e51 |
files | mercurial/templatekw.py tests/test-template-keywords.t |
diffstat | 2 files changed, 36 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatekw.py Tue Jul 24 22:33:08 2018 +0900 +++ b/mercurial/templatekw.py Tue Jul 24 22:13:21 2018 +0900 @@ -168,9 +168,8 @@ @templatekeyword('author', requires={'ctx'}) def showauthor(context, mapping): - """String. The unmodified author of the changeset.""" - ctx = context.resource(mapping, 'ctx') - return ctx.user() + """Alias for ``{user}``""" + return showuser(context, mapping) @templatekeyword('bisect', requires={'repo', 'ctx'}) def showbisect(context, mapping): @@ -757,6 +756,12 @@ ui = context.resource(mapping, 'ui') return ui.termwidth() +@templatekeyword('user', requires={'ctx'}) +def showuser(context, mapping): + """String. The unmodified author of the changeset.""" + ctx = context.resource(mapping, 'ctx') + return ctx.user() + @templatekeyword('instabilities', requires={'ctx'}) def showinstabilities(context, mapping): """List of strings. Evolution instabilities affecting the changeset.
--- a/tests/test-template-keywords.t Tue Jul 24 22:33:08 2018 +0900 +++ b/tests/test-template-keywords.t Tue Jul 24 22:13:21 2018 +0900 @@ -91,7 +91,7 @@ $ for key in author branch branches date desc file_adds file_dels file_mods \ > file_copies file_copies_switch files \ > manifest node parents rev tags diffstat extras \ - > p1rev p2rev p1node p2node; do + > p1rev p2rev p1node p2node user; do > for mode in '' --verbose --debug; do > hg log $mode --template "$key$mode: {$key}\n" > done @@ -702,6 +702,33 @@ p2node--debug: 0000000000000000000000000000000000000000 p2node--debug: 0000000000000000000000000000000000000000 p2node--debug: 0000000000000000000000000000000000000000 + user: test + user: User Name <user@hostname> + user: person + user: person + user: person + user: person + user: other@place + user: A. N. Other <other@place> + user: User Name <user@hostname> + user--verbose: test + user--verbose: User Name <user@hostname> + user--verbose: person + user--verbose: person + user--verbose: person + user--verbose: person + user--verbose: other@place + user--verbose: A. N. Other <other@place> + user--verbose: User Name <user@hostname> + user--debug: test + user--debug: User Name <user@hostname> + user--debug: person + user--debug: person + user--debug: person + user--debug: person + user--debug: other@place + user--debug: A. N. Other <other@place> + user--debug: User Name <user@hostname> Add a dummy commit to make up for the instability of the above: