Patchwork [2,of,3] fix_bytes: loosen blacklist matching requirements

login
register
mail settings
Submitter Gregory Szorc
Date May 10, 2014, 11:39 p.m.
Message ID <8a49e0cb7f14a69662da.1399765196@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4727/
State Superseded
Commit 48ef68004ec949e9da3b178a40cbaf6ab8039a48
Headers show

Comments

Gregory Szorc - May 10, 2014, 11:39 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1399758879 25200
#      Sat May 10 14:54:39 2014 -0700
# Node ID 8a49e0cb7f14a69662da24d71ec2d4ab3f536df3
# Parent  c59dd2bd4a28c4ce6438f15c9cfa612bb1e74162
fix_bytes: loosen blacklist matching requirements
Augie Fackler - May 13, 2014, 12:58 a.m.
On Sat, May 10, 2014 at 04:39:56PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1399758879 25200
> #      Sat May 10 14:54:39 2014 -0700
> # Node ID 8a49e0cb7f14a69662da24d71ec2d4ab3f536df3
> # Parent  c59dd2bd4a28c4ce6438f15c9cfa612bb1e74162
> fix_bytes: loosen blacklist matching requirements
>
> diff --git a/contrib/hgfixes/fix_bytes.py b/contrib/hgfixes/fix_bytes.py
> --- a/contrib/hgfixes/fix_bytes.py
> +++ b/contrib/hgfixes/fix_bytes.py
> @@ -11,12 +11,12 @@ from lib2to3.pygram import python_symbol
>
>  # XXX: Implementing a blacklist in 2to3 turned out to be more troublesome than
>  # blacklisting some modules inside the fixers. So, this is what I came with.
>
> -blacklist = ['mercurial/demandimport.py',
> +blacklist = ('mercurial/demandimport.py',
>               'mercurial/py3kcompat.py', # valid python 3 already
>               'mercurial/i18n.py',
> -            ]
> +            )

Why does this list change into a tuple? Could stand to be mentioned in
the subject.

>
>  def isdocstring(node):
>      def isclassorfunction(ancestor):
>          symbols = (syms.funcdef, syms.classdef)
> @@ -82,9 +82,10 @@ class FixBytes(fixer_base.BaseFix):
>
>      PATTERN = 'STRING'
>
>      def transform(self, node, results):
> -        if self.filename in blacklist:
> +        # The filename may be prefixed with a build directory.
> +        if self.filename.endswith(blacklist):
>              return
>          if node.type == token.STRING:
>              if _re.match(node.value):
>                  if isdocstring(node):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - May 15, 2014, 6:48 a.m.
On 05/10/2014 04:39 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1399758879 25200
> #      Sat May 10 14:54:39 2014 -0700
> # Node ID 8a49e0cb7f14a69662da24d71ec2d4ab3f536df3
> # Parent  c59dd2bd4a28c4ce6438f15c9cfa612bb1e74162
> fix_bytes: loosen blacklist matching requirements

Can  you be a bit more verbose on what this patches does and why it is 
necessary?

Patch

diff --git a/contrib/hgfixes/fix_bytes.py b/contrib/hgfixes/fix_bytes.py
--- a/contrib/hgfixes/fix_bytes.py
+++ b/contrib/hgfixes/fix_bytes.py
@@ -11,12 +11,12 @@  from lib2to3.pygram import python_symbol
 
 # XXX: Implementing a blacklist in 2to3 turned out to be more troublesome than
 # blacklisting some modules inside the fixers. So, this is what I came with.
 
-blacklist = ['mercurial/demandimport.py',
+blacklist = ('mercurial/demandimport.py',
              'mercurial/py3kcompat.py', # valid python 3 already
              'mercurial/i18n.py',
-            ]
+            )
 
 def isdocstring(node):
     def isclassorfunction(ancestor):
         symbols = (syms.funcdef, syms.classdef)
@@ -82,9 +82,10 @@  class FixBytes(fixer_base.BaseFix):
 
     PATTERN = 'STRING'
 
     def transform(self, node, results):
-        if self.filename in blacklist:
+        # The filename may be prefixed with a build directory.
+        if self.filename.endswith(blacklist):
             return
         if node.type == token.STRING:
             if _re.match(node.value):
                 if isdocstring(node):