Patchwork tests: simplify and document the sorting of pyflake messages

login
register
mail settings
Submitter Simon Heimberg
Date June 14, 2013, 10:07 p.m.
Message ID <7a35b0923e5f76d96f8e.1371247635@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1730/
State Superseded, archived
Commit 77440de177f799f9f3bd6236c5b45fb8e15687e7
Headers show

Comments

Simon Heimberg - June 14, 2013, 10:07 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1371247580 -7200
# Node ID 7a35b0923e5f76d96f8e789071adf81e4862301f
# Parent  f235457a184b6003495f1a5b6c1003590186f1ab
tests: simplify and document the sorting of pyflake messages

The pyflake messages are simply ordered by message type, path and line no.
The other details are not used for sorting.

The previous ordering looks complicated and illogically.
It was the following order ('\3:\5:\4:\1:\2:' + line):
  message (\3 and \5)
  var name (\4)
  path (\1)
  line no (\2)
  line reference
Ordering by var name before path looks illogically for me.
Augie Fackler - June 24, 2013, 7:48 p.m.
On Sat, Jun 15, 2013 at 12:07:15AM +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1371247580 -7200
> # Node ID 7a35b0923e5f76d96f8e789071adf81e4862301f
> # Parent  f235457a184b6003495f1a5b6c1003590186f1ab
> tests: simplify and document the sorting of pyflake messages
>
> The pyflake messages are simply ordered by message type, path and line no.
> The other details are not used for sorting.
>
> The previous ordering looks complicated and illogically.
> It was the following order ('\3:\5:\4:\1:\2:' + line):
>   message (\3 and \5)
>   var name (\4)
>   path (\1)
>   line no (\2)
>   line reference
> Ordering by var name before path looks illogically for me.
>
> diff -r f235457a184b -r 7a35b0923e5f tests/filterpyflakes.py
> --- a/tests/filterpyflakes.py	Sam Jun 15 00:04:51 2013 +0200
> +++ b/tests/filterpyflakes.py	Sam Jun 15 00:06:20 2013 +0200
> @@ -5,15 +5,12 @@
>  import sys, re, os
>
>  def makekey(message):
> +    "order by: message type, path/file, lineno"
>      # "path/file:line: message"

is this comment describing the input format?

> -    match = re.search(r"(line \d+)", message)
> -    line = ''
> -    if match:
> -        line = match.group(0)
> -        message = re.sub(r"(line \d+)", '', message)
> -    return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
> -                  r'\3:\5:\4:\1:\2:' + line,
> -                  message)
> +    m = message.split(':', 2)
> +    msg = re.sub("'.*'", "", re.sub(r"\([^\)]*\)", "", m[2]))
> +        # dropped var name and bracket content from msg
> +    return (msg, m[0], m[1])
>

This code (both old and new) is complex enough that I'd like to see
some simple doctests added to the docstring to make reviewing and
maintaining it more straightforward. Can I persuade you to follow up
with that?

>
>  lines = []
>  for line in sys.stdin:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - June 26, 2013, 7:05 p.m.
On Sat, 2013-06-15 at 00:07 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1371247580 -7200
> # Node ID 7a35b0923e5f76d96f8e789071adf81e4862301f
> # Parent  f235457a184b6003495f1a5b6c1003590186f1ab
> tests: simplify and document the sorting of pyflake messages
> 
> The pyflake messages are simply ordered by message type, path and line no.
> The other details are not used for sorting.
> 
> The previous ordering looks complicated and illogically.
> It was the following order ('\3:\5:\4:\1:\2:' + line):
>   message (\3 and \5)
>   var name (\4)
>   path (\1)
>   line no (\2)
>   line reference
> Ordering by var name before path looks illogically for me.

Queued for default, thanks. I suspect Augie is a little over-exposed to
the 'yo dawg' meme.
Simon Heimberg - June 26, 2013, 8:04 p.m.
I'd prefer to simplify the algorythm. Could you unqueue please? I will send the alternative patch soon.


-----Urspr√ľngliche Nachricht-----
Von: Matt Mackall [mailto:mpm@selenic.com] 
Gesendet: Mittwoch, 26. Juni 2013 21:06
An: Simon Heimberg
Cc: Mercurial-devel
Betreff: Re: [PATCH] tests: simplify and document the sorting of pyflake messages

On Sat, 2013-06-15 at 00:07 +0200, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch> # Date 1371247580 -7200 # 
> Node ID 7a35b0923e5f76d96f8e789071adf81e4862301f
> # Parent  f235457a184b6003495f1a5b6c1003590186f1ab
> tests: simplify and document the sorting of pyflake messages
> 
> The pyflake messages are simply ordered by message type, path and line no.
> The other details are not used for sorting.
> 
> The previous ordering looks complicated and illogically.
> It was the following order ('\3:\5:\4:\1:\2:' + line):
>   message (\3 and \5)
>   var name (\4)
>   path (\1)
>   line no (\2)
>   line reference
> Ordering by var name before path looks illogically for me.

Queued for default, thanks. I suspect Augie is a little over-exposed to the 'yo dawg' meme.

--
Mathematics is the supreme nostalgia of our time.

Patch

diff -r f235457a184b -r 7a35b0923e5f tests/filterpyflakes.py
--- a/tests/filterpyflakes.py	Sam Jun 15 00:04:51 2013 +0200
+++ b/tests/filterpyflakes.py	Sam Jun 15 00:06:20 2013 +0200
@@ -5,15 +5,12 @@ 
 import sys, re, os
 
 def makekey(message):
+    "order by: message type, path/file, lineno"
     # "path/file:line: message"
-    match = re.search(r"(line \d+)", message)
-    line = ''
-    if match:
-        line = match.group(0)
-        message = re.sub(r"(line \d+)", '', message)
-    return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$",
-                  r'\3:\5:\4:\1:\2:' + line,
-                  message)
+    m = message.split(':', 2)
+    msg = re.sub("'.*'", "", re.sub(r"\([^\)]*\)", "", m[2]))
+        # dropped var name and bracket content from msg
+    return (msg, m[0], m[1])
 
 lines = []
 for line in sys.stdin: