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

Yuya Nishihara yuya at tcha.org
Thu Oct 2 10:50:20 CDT 2014


On Thu, 02 Oct 2014 17:23:32 +0200, Mads Kiilerich wrote:
> On 10/02/2014 04:59 PM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1412255739 -32400
> > #      Thu Oct 02 22:15:39 2014 +0900
> > # Node ID 04e13b88d3b047406ca954fbb79de228874817eb
> > # Parent  4ec9dd1b52889c73bbf39159222a161e4374cd4a
> > 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
> > @@ -1119,8 +1119,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()
> > +        fmt = ' ' * max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
> > +        fmt += '%d:%s'
> 
> I think it is sad that our 80 characters line limit cause us to spend 
> extra cpu cycles. It will not make a real difference here but it just 
> feels wrong. I have a hard time trying to understand how this can be 
> more readable than a multi line statement.

Ok, I'll do

  padsize = ...
  fmt = ' ' * padsize + '%d:%s'

Regards,


More information about the Mercurial-devel mailing list