fix_bytesmod: fix defects in fix_bytesmod so it produces working code
authorAugie Fackler <raf@durin42.com>
Tue, 04 Feb 2014 18:09:20 -0500
changeset 20399 74daabdf5ab5
parent 20398 2bc520bd0ce0
child 20400 f0137d994c83
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.
contrib/hgfixes/fix_bytesmod.py
--- 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
-