Patchwork check-code: prepend warning prefix for repeated warnings only once

login
register
mail settings
Submitter Simon Heimberg
Date Nov. 2, 2013, 10:30 a.m.
Message ID <1f6e8488b6c7eab2186c.1383388250@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/2837/
State Accepted
Commit 3e1e4a8aec1e58f715991c62216ae534dd07e010
Headers show

Comments

Simon Heimberg - Nov. 2, 2013, 10:30 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1383387904 -3600
#      Sat Nov 02 11:25:04 2013 +0100
# Branch stable
# Node ID 1f6e8488b6c7eab2186c53cc508b7afbb2731caa
# Parent  d24ee6d7d16730efe4b0894e0cb7c3e931411963
check-code: prepend warning prefix for repeated warnings only once

When a warning occured several times in one file, "warning: " was prepended
several times:

examplefile.py:3:
 > def a(object):
 warning: this looks wrong
examplefile.py:27:
 > def x(object):
 warning: warning: this looks wrong
Augie Fackler - Nov. 5, 2013, 6:25 p.m.
On Sat, Nov 02, 2013 at 11:30:50AM +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1383387904 -3600
> #      Sat Nov 02 11:25:04 2013 +0100
> # Branch stable
> # Node ID 1f6e8488b6c7eab2186c53cc508b7afbb2731caa
> # Parent  d24ee6d7d16730efe4b0894e0cb7c3e931411963
> check-code: prepend warning prefix for repeated warnings only once

also queued for stable

>
> When a warning occured several times in one file, "warning: " was prepended
> several times:
>
> examplefile.py:3:
>  > def a(object):
>  warning: this looks wrong
> examplefile.py:27:
>  > def x(object):
>  warning: warning: this looks wrong
>
> diff -r d24ee6d7d167 -r 1f6e8488b6c7 contrib/check-code.py
> --- a/contrib/check-code.py	Fri Nov 01 17:04:18 2013 -0500
> +++ b/contrib/check-code.py	Sat Nov 02 11:25:04 2013 +0100
> @@ -456,6 +456,8 @@
>                  if prelines is None:
>                      prelines = pre.splitlines()
>                      postlines = post.splitlines(True)
> +                    if i >= nerrs:
> +                        msg = "warning: " + msg
>
>                  start = m.start()
>                  while n < len(postlines):
> @@ -482,8 +484,6 @@
>                          bl, bu, br = blamecache[n]
>                          if bl == l:
>                              bd = '%s@%s' % (bu, br)
> -                if i >= nerrs:
> -                    msg = "warning: " + msg
>                  errors.append((f, lineno and n + 1, l, msg, bd))
>                  result = False
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r d24ee6d7d167 -r 1f6e8488b6c7 contrib/check-code.py
--- a/contrib/check-code.py	Fri Nov 01 17:04:18 2013 -0500
+++ b/contrib/check-code.py	Sat Nov 02 11:25:04 2013 +0100
@@ -456,6 +456,8 @@ 
                 if prelines is None:
                     prelines = pre.splitlines()
                     postlines = post.splitlines(True)
+                    if i >= nerrs:
+                        msg = "warning: " + msg
 
                 start = m.start()
                 while n < len(postlines):
@@ -482,8 +484,6 @@ 
                         bl, bu, br = blamecache[n]
                         if bl == l:
                             bd = '%s@%s' % (bu, br)
-                if i >= nerrs:
-                    msg = "warning: " + msg
                 errors.append((f, lineno and n + 1, l, msg, bd))
                 result = False