[PATCH 5 of 5] branches: populate all template keywords in formatter

Yuya Nishihara yuya at tcha.org
Sat Feb 25 09:51:34 EST 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1488010122 -32400
#      Sat Feb 25 17:08:42 2017 +0900
# Node ID 274456919eb7b71490ed32dedcd36ffc3bb9ef6e
# Parent  8875d9bcb7f8b8c119b6e25b15335cb4253b8252
# EXP-Topic formatter
branches: populate all template keywords in formatter

This is a usage example of fm.context().

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1253,6 +1253,7 @@ def branches(ui, repo, active=False, clo
         fmt = ' ' * padsize + ' %d:%s'
         fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
                      label='log.changeset changeset.%s' % ctx.phasestr())
+        fm.context(ctx=ctx)
         fm.data(active=isactive, closed=not isopen, current=current)
         if not ui.quiet:
             fm.plain(notice)
diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -519,6 +519,12 @@ template output:
   $ hg branches --closed -T '{if(closed, "{branch}\n")}'
   c
 
+  $ hg branches -T '{word(0, branch)}: {desc|firstline}\n'
+  b: reopen branch with a change
+  a: Adding d branch
+  a: Adding b branch head 2
+  default: Adding root node
+
 Tests of revision branch name caching
 
 We rev branch cache is updated automatically. In these tests we use a trick to


More information about the Mercurial-devel mailing list