branches: reduce nesting in for loop
authorYuya Nishihara <yuya@tcha.org>
Thu, 02 Oct 2014 21:58:10 +0900
changeset 22639 79c4178b2169
parent 22638 0d0350cfc7ab
child 22640 e88a634e0195
branches: reduce nesting in for loop
mercurial/commands.py
--- 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')),