# HG changeset patch # User Yuya Nishihara # Date 1532438001 -32400 # Node ID 390287321b4b72a9cd98da2f1017c274177d4da2 # Parent f9a98075a37ea305c4091cff70b7ccfa660a7832 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 diff -r f9a98075a37e -r 390287321b4b mercurial/templatekw.py --- 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. diff -r f9a98075a37e -r 390287321b4b tests/test-template-keywords.t --- 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: person + user: person + user: person + user: person + user: other@place + user: A. N. Other + user: User Name + user--verbose: test + user--verbose: User Name + user--verbose: person + user--verbose: person + user--verbose: person + user--verbose: person + user--verbose: other@place + user--verbose: A. N. Other + user--verbose: User Name + user--debug: test + user--debug: User Name + user--debug: person + user--debug: person + user--debug: person + user--debug: person + user--debug: other@place + user--debug: A. N. Other + user--debug: User Name Add a dummy commit to make up for the instability of the above: