comparison 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
comparison
equal deleted inserted replaced
20398:2bc520bd0ce0 20399:74daabdf5ab5
31 term< formatstr=NAME '%' data=any > | 31 term< formatstr=NAME '%' data=any > |
32 term< formatstr=any '%' data=any > 32 term< formatstr=any '%' data=any >
33 ''' 33 '''
34 34
35 def transform(self, node, results): 35 def transform(self, node, results):
36 if self.filename in blacklist: 36 for bfn in blacklist:
37 return 37 if self.filename.endswith(bfn):
38 elif self.filename == 'mercurial/util.py': 38 return
39 if not self.filename.endswith('mercurial/py3kcompat.py'):
39 touch_import('.', 'py3kcompat', node=node) 40 touch_import('.', 'py3kcompat', node=node)
40 41
41 formatstr = results['formatstr'].clone() 42 formatstr = results['formatstr'].clone()
42 data = results['data'].clone() 43 data = results['data'].clone()
43 formatstr.prefix = '' # remove spaces from start 44 formatstr.prefix = '' # remove spaces from start
58 else: 59 else:
59 args = [formatstr, Comma().clone(), data] 60 args = [formatstr, Comma().clone(), data]
60 61
61 call = Call(Name('bytesformatter', prefix=' '), args) 62 call = Call(Name('bytesformatter', prefix=' '), args)
62 return call 63 return call
63