Mercurial > public > mercurial-scm > hg
comparison contrib/check-code.py @ 29277:79a11506803f
check-code: use fixedmap for replacement of space characters
This can centralize management of fixed replacement into fixedmap.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 31 May 2016 21:02:30 +0900 |
parents | 4dd530df4742 |
children | 5eda83fb09fc |
comparison
equal
deleted
inserted
replaced
29276:4dd530df4742 | 29277:79a11506803f |
---|---|
49 except re2.error: | 49 except re2.error: |
50 pass | 50 pass |
51 return re.compile(pat) | 51 return re.compile(pat) |
52 | 52 |
53 def repquote(m): | 53 def repquote(m): |
54 fixedmap = {'.': 'p', ':': 'q'} | 54 fixedmap = {' ': ' ', '\n': '\n', '.': 'p', ':': 'q'} |
55 def encodechr(i): | 55 def encodechr(i): |
56 if i > 255: | 56 if i > 255: |
57 return 'u' | 57 return 'u' |
58 c = chr(i) | 58 c = chr(i) |
59 if c in ' \n': | |
60 return c | |
61 if c in fixedmap: | 59 if c in fixedmap: |
62 return fixedmap[c] | 60 return fixedmap[c] |
63 if c.isalpha(): | 61 if c.isalpha(): |
64 return 'x' | 62 return 'x' |
65 if c.isdigit(): | 63 if c.isdigit(): |