diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -188,6 +188,7 @@ def showbranches(**args): branch = args['ctx'].branch() if branch != 'default': return showlist('branch', [branch], plural='branches', **args) + return showlist('branch', [], plural='branches', **args) def showbookmarks(**args): """:bookmarks: List of strings. Any bookmarks associated with the 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 @@ -1606,3 +1606,8 @@ Test recursive evaluation: {rev} $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n' test 0 + +Test branches inside if statement: + + $ hg log -r 0 --template '{if(branches, "yes", "no")}\n' + no