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.
--- 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
-