Mercurial > hg
changeset 22639:79c4178b2169
branches: reduce nesting in for loop
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 02 Oct 2014 21:58:10 +0900 |
parents | 0d0350cfc7ab |
children | e88a634e0195 |
files | mercurial/commands.py |
diffstat | 1 files changed, 23 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sun Sep 28 16:57:47 2014 +0200 +++ b/mercurial/commands.py Thu Oct 02 21:58:10 2014 +0900 @@ -1104,28 +1104,29 @@ reverse=True) for tag, ctx, isactive, isopen in branches: - if (not active) or isactive: - if isactive: - label = 'branches.active' - notice = '' - elif not isopen: - if not closed: - continue - label = 'branches.closed' - notice = _(' (closed)') - else: - label = 'branches.inactive' - 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())), - 'log.changeset changeset.%s' % ctx.phasestr()) - labeledtag = ui.label(tag, label) - if ui.quiet: - ui.write("%s\n" % labeledtag) - else: - ui.write("%s %s%s\n" % (labeledtag, rev, notice)) + if active and not isactive: + continue + if isactive: + label = 'branches.active' + notice = '' + elif not isopen: + if not closed: + continue + label = 'branches.closed' + notice = _(' (closed)') + else: + label = 'branches.inactive' + 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())), + 'log.changeset changeset.%s' % ctx.phasestr()) + labeledtag = ui.label(tag, label) + if ui.quiet: + ui.write("%s\n" % labeledtag) + else: + ui.write("%s %s%s\n" % (labeledtag, rev, notice)) @command('bundle', [('f', 'force', None, _('run even when the destination is unrelated')),