Patchwork annotate: remove redundant check for empty list of annotation data

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 16, 2014, 4:02 p.m.
Message ID <aa4f7635b201f3eef77c.1410883353@mimosa>
Download mbox | patch
Permalink /patch/5831/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 16, 2014, 4:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1409281799 -7200
#      Fri Aug 29 05:09:59 2014 +0200
# Node ID aa4f7635b201f3eef77c7777d0a831c6cc068616
# Parent  161fd3b412acce6ff0d364d41618bd1a627b3877
annotate: remove redundant check for empty list of annotation data

It isn't necessary because zip(*pieces) returns [] if pieces are empty,
and pieces are empty only if lines are empty.
Matt Mackall - Sept. 16, 2014, 4:50 p.m.
On Wed, 2014-09-17 at 01:02 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1409281799 -7200
> #      Fri Aug 29 05:09:59 2014 +0200
> # Node ID aa4f7635b201f3eef77c7777d0a831c6cc068616
> # Parent  161fd3b412acce6ff0d364d41618bd1a627b3877
> annotate: remove redundant check for empty list of annotation data

Queued for default, thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -323,12 +323,11 @@  def annotate(ui, repo, *pats, **opts):
                 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
                                for x, w in sized])
 
-        if pieces:
-            for p, l in zip(zip(*pieces), lines):
-                ui.write("%s: %s" % ("".join(p), l[1]))
-
-            if lines and not lines[-1][1].endswith('\n'):
-                ui.write('\n')
+        for p, l in zip(zip(*pieces), lines):
+            ui.write("%s: %s" % ("".join(p), l[1]))
+
+        if lines and not lines[-1][1].endswith('\n'):
+            ui.write('\n')
 
 @command('archive',
     [('', 'no-decode', None, _('do not pass files through decoders')),