[PATCH] template: add showbranch template for {branch}
Eric Eisner
ede at MIT.EDU
Mon Dec 13 09:30:59 CST 2010
# HG changeset patch
# User Eric Eisner <ede at mit.edu>
# Date 1292254215 18000
# Node ID 24e67dc52c257db32a3322f6784a0ad8e9cb42d0
# Parent bf763946f8b09fd23aa7835f44c8699998a8c389
template: add showbranch template for {branch}
Like showbranches, but always yields exactly one branch. Replaces the less
correct {branches|nonempty}.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -145,6 +145,9 @@ def getrenamedfn(repo, endrev=None):
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 @@ def showtags(**args):
# revcache - a cache dictionary for the current revision
keywords = {
'author': showauthor,
+ 'branch': showbranch,
'branches': showbranches,
'children': showchildren,
'date': showdate,
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -570,7 +570,7 @@ Issue2130: xml output for 'hg heads' is
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 @@ Keys work:
author--debug: other at place
author--debug: A. N. Other <other at place>
author--debug: User Name <user at hostname>
+ 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:
More information about the Mercurial-devel
mailing list