# HG changeset patch # User Eric Eisner # Date 1292254215 18000 # Node ID d79fdff556271ada20ccd22ab188b17e09faba0f # Parent f02d7a562a21540b93e88cf738f4e14f38ce3f0b template: add showbranch template for {branch} Like showbranches, but always yields exactly one branch. Replaces the less correct {branches|nonempty}. diff -r f02d7a562a21 -r d79fdff55627 mercurial/templatekw.py --- a/mercurial/templatekw.py Mon Nov 29 09:37:23 2010 +0100 +++ b/mercurial/templatekw.py Mon Dec 13 10:30:15 2010 -0500 @@ -145,6 +145,9 @@ def showauthor(repo, ctx, templ, **args): return ctx.user() +def showbranch(**args): + return args['ctx'].branch() + def showbranches(**args): branch = args['ctx'].branch() if branch != 'default': @@ -247,6 +250,7 @@ # revcache - a cache dictionary for the current revision keywords = { 'author': showauthor, + 'branch': showbranch, 'branches': showbranches, 'children': showchildren, 'date': showdate, diff -r f02d7a562a21 -r d79fdff55627 tests/test-command-template.t --- a/tests/test-command-template.t Mon Nov 29 09:37:23 2010 +0100 +++ b/tests/test-command-template.t Mon Dec 13 10:30:15 2010 -0500 @@ -570,7 +570,7 @@ Keys work: - $ for key in author branches date desc file_adds file_dels file_mods \ + $ 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; do > for mode in '' --verbose --debug; do @@ -604,6 +604,33 @@ author--debug: other@place author--debug: A. N. Other author--debug: User Name + branch: default + branch: default + branch: default + branch: default + branch: foo + branch: default + branch: default + branch: default + branch: default + branch--verbose: default + branch--verbose: default + branch--verbose: default + branch--verbose: default + branch--verbose: foo + branch--verbose: default + branch--verbose: default + branch--verbose: default + branch--verbose: default + branch--debug: default + branch--debug: default + branch--debug: default + branch--debug: default + branch--debug: foo + branch--debug: default + branch--debug: default + branch--debug: default + branch--debug: default branches: branches: branches: