[PATCH 2 of 5 V2] branches: format rev as integer that is necessary for generic templater

Yuya Nishihara yuya at tcha.org
Fri Oct 3 09:02:06 CDT 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1412255739 -32400
#      Thu Oct 02 22:15:39 2014 +0900
# Node ID f143a558f682d5426d7ece84b42cf6dcc217309d
# Parent  7437e043012b8fe79b8e08db290de4a28d9ddc57
branches: format rev as integer that is necessary for generic templater

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1116,8 +1116,10 @@ def branches(ui, repo, active=False, clo
             notice = _(' (inactive)')
         if tag == repo.dirstate.branch():
             label = 'branches.current'
-        rev = str(ctx.rev()).rjust(31 - encoding.colwidth(tag))
-        rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
+        rev = ctx.rev()
+        padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
+        fmt = ' ' * padsize + '%d:%s'
+        rev = ui.label(fmt % (rev, hexfunc(ctx.node())),
                        'log.changeset changeset.%s' % ctx.phasestr())
         labeledtag = ui.label(tag, label)
         if ui.quiet:


More information about the Mercurial-devel mailing list