Patchwork fix_bytes: loosen blacklist matching requirements

login
register
mail settings
Submitter Gregory Szorc
Date May 16, 2014, 9:22 p.m.
Message ID <6c7d19fe4b29a71e5c4d.1400275322@gps-mbp.local>
Download mbox | patch
Permalink /patch/4787/
State Accepted
Commit 48ef68004ec949e9da3b178a40cbaf6ab8039a48
Headers show

Comments

Gregory Szorc - May 16, 2014, 9:22 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 6c7d19fe4b29a71e5c4d3fc40ddad3a8d83ca65e
# Parent  1ae3cd6f836c3c96ee3e9a872c8e966750910c2d
fix_bytes: loosen blacklist matching requirements

On my Linux machine, paths seen by 2to3 include the build directory. We
switch from an exact to substring match to allow 2to3 to work in more
environments.
Matt Mackall - May 29, 2014, 10:56 p.m.
On Fri, 2014-05-16 at 14:22 -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 6c7d19fe4b29a71e5c4d3fc40ddad3a8d83ca65e
> # Parent  1ae3cd6f836c3c96ee3e9a872c8e966750910c2d
> fix_bytes: loosen blacklist matching requirements

Queued for default, thanks.

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):