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

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 3, 2014, 2:02 p.m.
Message ID <f143a558f682d5426d7e.1412344926@mimosa>
Download mbox | patch
Permalink /patch/6091/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 3, 2014, 2:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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

Patch

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: