diff contrib/hgfixes/fix_bytesmod.py @ 20399:74daabdf5ab5

fix_bytesmod: fix defects in fix_bytesmod so it produces working code Prior to this change, the fixer did not always add the py3kcompat import to files, and did not manage to blacklist itself.
author Augie Fackler <raf@durin42.com>
date Tue, 04 Feb 2014 18:09:20 -0500
parents 681f7b9213a4
children d20817ac628a
line wrap: on
line diff
--- a/contrib/hgfixes/fix_bytesmod.py	Thu Feb 06 02:19:38 2014 +0100
+++ b/contrib/hgfixes/fix_bytesmod.py	Tue Feb 04 18:09:20 2014 -0500
@@ -33,9 +33,10 @@
               '''
 
     def transform(self, node, results):
-        if self.filename in blacklist:
-            return
-        elif self.filename == 'mercurial/util.py':
+        for bfn in blacklist:
+            if self.filename.endswith(bfn):
+                return
+        if not self.filename.endswith('mercurial/py3kcompat.py'):
             touch_import('.', 'py3kcompat', node=node)
 
         formatstr = results['formatstr'].clone()
@@ -60,4 +61,3 @@
 
         call = Call(Name('bytesformatter', prefix=' '), args)
         return call
-