##// END OF EJS Templates
tests: run most check-code sh checks on continued lines too...
Mads Kiilerich -
r16672:d046eb97 default
parent child Browse files
Show More
@@ -1,437 +1,438
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 #
2 #
3 # check-code - a style and portability checker for Mercurial
3 # check-code - a style and portability checker for Mercurial
4 #
4 #
5 # Copyright 2010 Matt Mackall <mpm@selenic.com>
5 # Copyright 2010 Matt Mackall <mpm@selenic.com>
6 #
6 #
7 # This software may be used and distributed according to the terms of the
7 # This software may be used and distributed according to the terms of the
8 # GNU General Public License version 2 or any later version.
8 # GNU General Public License version 2 or any later version.
9
9
10 import re, glob, os, sys
10 import re, glob, os, sys
11 import keyword
11 import keyword
12 import optparse
12 import optparse
13
13
14 def repquote(m):
14 def repquote(m):
15 t = re.sub(r"\w", "x", m.group('text'))
15 t = re.sub(r"\w", "x", m.group('text'))
16 t = re.sub(r"[^\s\nx]", "o", t)
16 t = re.sub(r"[^\s\nx]", "o", t)
17 return m.group('quote') + t + m.group('quote')
17 return m.group('quote') + t + m.group('quote')
18
18
19 def reppython(m):
19 def reppython(m):
20 comment = m.group('comment')
20 comment = m.group('comment')
21 if comment:
21 if comment:
22 return "#" * len(comment)
22 return "#" * len(comment)
23 return repquote(m)
23 return repquote(m)
24
24
25 def repcomment(m):
25 def repcomment(m):
26 return m.group(1) + "#" * len(m.group(2))
26 return m.group(1) + "#" * len(m.group(2))
27
27
28 def repccomment(m):
28 def repccomment(m):
29 t = re.sub(r"((?<=\n) )|\S", "x", m.group(2))
29 t = re.sub(r"((?<=\n) )|\S", "x", m.group(2))
30 return m.group(1) + t + "*/"
30 return m.group(1) + t + "*/"
31
31
32 def repcallspaces(m):
32 def repcallspaces(m):
33 t = re.sub(r"\n\s+", "\n", m.group(2))
33 t = re.sub(r"\n\s+", "\n", m.group(2))
34 return m.group(1) + t
34 return m.group(1) + t
35
35
36 def repinclude(m):
36 def repinclude(m):
37 return m.group(1) + "<foo>"
37 return m.group(1) + "<foo>"
38
38
39 def rephere(m):
39 def rephere(m):
40 t = re.sub(r"\S", "x", m.group(2))
40 t = re.sub(r"\S", "x", m.group(2))
41 return m.group(1) + t
41 return m.group(1) + t
42
42
43
43
44 testpats = [
44 testpats = [
45 [
45 [
46 (r'pushd|popd', "don't use 'pushd' or 'popd', use 'cd'"),
46 (r'pushd|popd', "don't use 'pushd' or 'popd', use 'cd'"),
47 (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
47 (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
48 (r'^function', "don't use 'function', use old style"),
49 (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
48 (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
50 (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
49 (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
51 (r'echo.*\\n', "don't use 'echo \\n', use printf"),
50 (r'echo.*\\n', "don't use 'echo \\n', use printf"),
52 (r'echo -n', "don't use 'echo -n', use printf"),
51 (r'echo -n', "don't use 'echo -n', use printf"),
53 (r'^diff.*-\w*N', "don't use 'diff -N'"),
54 (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"),
52 (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"),
55 (r'head -c', "don't use 'head -c', use 'dd'"),
53 (r'head -c', "don't use 'head -c', use 'dd'"),
56 (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
54 (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
57 (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
55 (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
58 (r'printf.*\\([1-9]|0\d)', "don't use 'printf \NNN', use Python"),
56 (r'printf.*\\([1-9]|0\d)', "don't use 'printf \NNN', use Python"),
59 (r'printf.*\\x', "don't use printf \\x, use Python"),
57 (r'printf.*\\x', "don't use printf \\x, use Python"),
60 (r'\$\(.*\)', "don't use $(expr), use `expr`"),
58 (r'\$\(.*\)', "don't use $(expr), use `expr`"),
61 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
59 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
62 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
60 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
63 "use egrep for extended grep syntax"),
61 "use egrep for extended grep syntax"),
64 (r'/bin/', "don't use explicit paths for tools"),
62 (r'/bin/', "don't use explicit paths for tools"),
65 (r'\$PWD', "don't use $PWD, use `pwd`"),
66 (r'[^\n]\Z', "no trailing newline"),
63 (r'[^\n]\Z', "no trailing newline"),
67 (r'export.*=', "don't export and assign at once"),
64 (r'export.*=', "don't export and assign at once"),
68 (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\^', "^ must be quoted"),
69 (r'^source\b', "don't use 'source', use '.'"),
65 (r'^source\b', "don't use 'source', use '.'"),
70 (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
66 (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
71 (r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),
67 (r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),
72 (r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
68 (r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
73 (r'^stop\(\)', "don't use 'stop' as a shell function name"),
69 (r'^stop\(\)', "don't use 'stop' as a shell function name"),
74 (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
70 (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
75 (r'^alias\b.*=', "don't use alias, use a function"),
71 (r'^alias\b.*=', "don't use alias, use a function"),
76 (r'if\s*!', "don't use '!' to negate exit status"),
72 (r'if\s*!', "don't use '!' to negate exit status"),
77 (r'/dev/u?random', "don't use entropy, use /dev/zero"),
73 (r'/dev/u?random', "don't use entropy, use /dev/zero"),
78 (r'do\s*true;\s*done', "don't use true as loop body, use sleep 0"),
74 (r'do\s*true;\s*done', "don't use true as loop body, use sleep 0"),
79 (r'^( *)\t', "don't use tabs to indent"),
75 (r'^( *)\t', "don't use tabs to indent"),
80 ],
76 ],
81 # warnings
77 # warnings
82 []
78 [
79 (r'^function', "don't use 'function', use old style"),
80 (r'^diff.*-\w*N', "don't use 'diff -N'"),
81 (r'\$PWD', "don't use $PWD, use `pwd`"),
82 (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\^', "^ must be quoted"),
83 ]
83 ]
84 ]
84
85
85 testfilters = [
86 testfilters = [
86 (r"( *)(#([^\n]*\S)?)", repcomment),
87 (r"( *)(#([^\n]*\S)?)", repcomment),
87 (r"<<(\S+)((.|\n)*?\n\1)", rephere),
88 (r"<<(\S+)((.|\n)*?\n\1)", rephere),
88 ]
89 ]
89
90
90 uprefix = r"^ \$ "
91 uprefix = r"^ \$ "
91 utestpats = [
92 utestpats = [
92 [
93 [
93 (r'^(\S| $ ).*(\S[ \t]+|^[ \t]+)\n', "trailing whitespace on non-output"),
94 (r'^(\S| $ ).*(\S[ \t]+|^[ \t]+)\n', "trailing whitespace on non-output"),
94 (uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"),
95 (uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"),
95 (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
96 (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
96 (uprefix + r'.*(?<!\[)\$\?', "explicit exit code checks unnecessary"),
97 (uprefix + r'.*(?<!\[)\$\?', "explicit exit code checks unnecessary"),
97 (uprefix + r'.*\|\| echo.*(fail|error)',
98 (uprefix + r'.*\|\| echo.*(fail|error)',
98 "explicit exit code checks unnecessary"),
99 "explicit exit code checks unnecessary"),
99 (uprefix + r'set -e', "don't use set -e"),
100 (uprefix + r'set -e', "don't use set -e"),
100 (uprefix + r'\s', "don't indent commands, use > for continued lines"),
101 (uprefix + r'\s', "don't indent commands, use > for continued lines"),
101 ],
102 ],
102 # warnings
103 # warnings
103 []
104 []
104 ]
105 ]
105
106
106 for i in [0, 1]:
107 for i in [0, 1]:
107 for p, m in testpats[i]:
108 for p, m in testpats[i]:
108 if p.startswith(r'^'):
109 if p.startswith(r'^'):
109 p = r"^ \$ (%s)" % p[1:]
110 p = r"^ [$>] (%s)" % p[1:]
110 else:
111 else:
111 p = r"^ \$ .*(%s)" % p
112 p = r"^ [$>] .*(%s)" % p
112 utestpats[i].append((p, m))
113 utestpats[i].append((p, m))
113
114
114 utestfilters = [
115 utestfilters = [
115 (r"( *)(#([^\n]*\S)?)", repcomment),
116 (r"( *)(#([^\n]*\S)?)", repcomment),
116 ]
117 ]
117
118
118 pypats = [
119 pypats = [
119 [
120 [
120 (r'^\s*def\s*\w+\s*\(.*,\s*\(',
121 (r'^\s*def\s*\w+\s*\(.*,\s*\(',
121 "tuple parameter unpacking not available in Python 3+"),
122 "tuple parameter unpacking not available in Python 3+"),
122 (r'lambda\s*\(.*,.*\)',
123 (r'lambda\s*\(.*,.*\)',
123 "tuple parameter unpacking not available in Python 3+"),
124 "tuple parameter unpacking not available in Python 3+"),
124 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
125 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
125 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
126 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
126 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
127 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
127 (r'^\s*\t', "don't use tabs"),
128 (r'^\s*\t', "don't use tabs"),
128 (r'\S;\s*\n', "semicolon"),
129 (r'\S;\s*\n', "semicolon"),
129 (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),
130 (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),
130 (r"[^_]_\('[^']+'\s*%", "don't use % inside _()"),
131 (r"[^_]_\('[^']+'\s*%", "don't use % inside _()"),
131 (r'\w,\w', "missing whitespace after ,"),
132 (r'\w,\w', "missing whitespace after ,"),
132 (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
133 (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
133 (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"),
134 (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"),
134 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
135 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
135 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Py2.4'),
136 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Py2.4'),
136 (r'.{85}', "line too long"),
137 (r'.{85}', "line too long"),
137 (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
138 (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
138 (r'[^\n]\Z', "no trailing newline"),
139 (r'[^\n]\Z', "no trailing newline"),
139 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
140 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
140 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"),
141 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"),
141 (r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
142 (r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
142 "don't use camelcase in identifiers"),
143 "don't use camelcase in identifiers"),
143 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
144 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
144 "linebreak after :"),
145 "linebreak after :"),
145 (r'class\s[^( \n]+:', "old-style class, use class foo(object)"),
146 (r'class\s[^( \n]+:', "old-style class, use class foo(object)"),
146 (r'class\s[^( \n]+\(\):',
147 (r'class\s[^( \n]+\(\):',
147 "class foo() not available in Python 2.4, use class foo(object)"),
148 "class foo() not available in Python 2.4, use class foo(object)"),
148 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
149 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
149 "Python keyword is not a function"),
150 "Python keyword is not a function"),
150 (r',]', "unneeded trailing ',' in list"),
151 (r',]', "unneeded trailing ',' in list"),
151 # (r'class\s[A-Z][^\(]*\((?!Exception)',
152 # (r'class\s[A-Z][^\(]*\((?!Exception)',
152 # "don't capitalize non-exception classes"),
153 # "don't capitalize non-exception classes"),
153 # (r'in range\(', "use xrange"),
154 # (r'in range\(', "use xrange"),
154 # (r'^\s*print\s+', "avoid using print in core and extensions"),
155 # (r'^\s*print\s+', "avoid using print in core and extensions"),
155 (r'[\x80-\xff]', "non-ASCII character literal"),
156 (r'[\x80-\xff]', "non-ASCII character literal"),
156 (r'("\')\.format\(', "str.format() not available in Python 2.4"),
157 (r'("\')\.format\(', "str.format() not available in Python 2.4"),
157 (r'^\s*with\s+', "with not available in Python 2.4"),
158 (r'^\s*with\s+', "with not available in Python 2.4"),
158 (r'\.isdisjoint\(', "set.isdisjoint not available in Python 2.4"),
159 (r'\.isdisjoint\(', "set.isdisjoint not available in Python 2.4"),
159 (r'^\s*except.* as .*:', "except as not available in Python 2.4"),
160 (r'^\s*except.* as .*:', "except as not available in Python 2.4"),
160 (r'^\s*os\.path\.relpath', "relpath not available in Python 2.4"),
161 (r'^\s*os\.path\.relpath', "relpath not available in Python 2.4"),
161 (r'(?<!def)\s+(any|all|format)\(',
162 (r'(?<!def)\s+(any|all|format)\(',
162 "any/all/format not available in Python 2.4"),
163 "any/all/format not available in Python 2.4"),
163 (r'(?<!def)\s+(callable)\(',
164 (r'(?<!def)\s+(callable)\(',
164 "callable not available in Python 3, use getattr(f, '__call__', None)"),
165 "callable not available in Python 3, use getattr(f, '__call__', None)"),
165 (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
166 (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
166 (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist),
167 (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist),
167 "gratuitous whitespace after Python keyword"),
168 "gratuitous whitespace after Python keyword"),
168 (r'([\(\[][ \t]\S)|(\S[ \t][\)\]])', "gratuitous whitespace in () or []"),
169 (r'([\(\[][ \t]\S)|(\S[ \t][\)\]])', "gratuitous whitespace in () or []"),
169 # (r'\s\s=', "gratuitous whitespace before ="),
170 # (r'\s\s=', "gratuitous whitespace before ="),
170 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
171 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
171 "missing whitespace around operator"),
172 "missing whitespace around operator"),
172 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s',
173 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s',
173 "missing whitespace around operator"),
174 "missing whitespace around operator"),
174 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
175 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
175 "missing whitespace around operator"),
176 "missing whitespace around operator"),
176 (r'[^^+=*/!<>&| -](\s=|=\s)[^= ]',
177 (r'[^^+=*/!<>&| -](\s=|=\s)[^= ]',
177 "wrong whitespace around ="),
178 "wrong whitespace around ="),
178 (r'raise Exception', "don't raise generic exceptions"),
179 (r'raise Exception', "don't raise generic exceptions"),
179 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
180 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
180 (r' [=!]=\s+(True|False|None)',
181 (r' [=!]=\s+(True|False|None)',
181 "comparison with singleton, use 'is' or 'is not' instead"),
182 "comparison with singleton, use 'is' or 'is not' instead"),
182 (r'^\s*(while|if) [01]:',
183 (r'^\s*(while|if) [01]:',
183 "use True/False for constant Boolean expression"),
184 "use True/False for constant Boolean expression"),
184 (r'(?:(?<!def)\s+|\()hasattr',
185 (r'(?:(?<!def)\s+|\()hasattr',
185 'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'),
186 'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'),
186 (r'opener\([^)]*\).read\(',
187 (r'opener\([^)]*\).read\(',
187 "use opener.read() instead"),
188 "use opener.read() instead"),
188 (r'BaseException', 'not in Py2.4, use Exception'),
189 (r'BaseException', 'not in Py2.4, use Exception'),
189 (r'os\.path\.relpath', 'os.path.relpath is not in Py2.5'),
190 (r'os\.path\.relpath', 'os.path.relpath is not in Py2.5'),
190 (r'opener\([^)]*\).write\(',
191 (r'opener\([^)]*\).write\(',
191 "use opener.write() instead"),
192 "use opener.write() instead"),
192 (r'[\s\(](open|file)\([^)]*\)\.read\(',
193 (r'[\s\(](open|file)\([^)]*\)\.read\(',
193 "use util.readfile() instead"),
194 "use util.readfile() instead"),
194 (r'[\s\(](open|file)\([^)]*\)\.write\(',
195 (r'[\s\(](open|file)\([^)]*\)\.write\(',
195 "use util.readfile() instead"),
196 "use util.readfile() instead"),
196 (r'^[\s\(]*(open(er)?|file)\([^)]*\)',
197 (r'^[\s\(]*(open(er)?|file)\([^)]*\)',
197 "always assign an opened file to a variable, and close it afterwards"),
198 "always assign an opened file to a variable, and close it afterwards"),
198 (r'[\s\(](open|file)\([^)]*\)\.',
199 (r'[\s\(](open|file)\([^)]*\)\.',
199 "always assign an opened file to a variable, and close it afterwards"),
200 "always assign an opened file to a variable, and close it afterwards"),
200 (r'(?i)descendent', "the proper spelling is descendAnt"),
201 (r'(?i)descendent', "the proper spelling is descendAnt"),
201 (r'\.debug\(\_', "don't mark debug messages for translation"),
202 (r'\.debug\(\_', "don't mark debug messages for translation"),
202 (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
203 (r'\.strip\(\)\.split\(\)', "no need to strip before splitting"),
203 ],
204 ],
204 # warnings
205 # warnings
205 [
206 [
206 (r'.{81}', "warning: line over 80 characters"),
207 (r'.{81}', "warning: line over 80 characters"),
207 (r'^\s*except:$', "warning: naked except clause"),
208 (r'^\s*except:$', "warning: naked except clause"),
208 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
209 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
209 "warning: unwrapped ui message"),
210 "warning: unwrapped ui message"),
210 ]
211 ]
211 ]
212 ]
212
213
213 pyfilters = [
214 pyfilters = [
214 (r"""(?msx)(?P<comment>\#.*?$)|
215 (r"""(?msx)(?P<comment>\#.*?$)|
215 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
216 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
216 (?P<text>(([^\\]|\\.)*?))
217 (?P<text>(([^\\]|\\.)*?))
217 (?P=quote))""", reppython),
218 (?P=quote))""", reppython),
218 ]
219 ]
219
220
220 cpats = [
221 cpats = [
221 [
222 [
222 (r'//', "don't use //-style comments"),
223 (r'//', "don't use //-style comments"),
223 (r'^ ', "don't use spaces to indent"),
224 (r'^ ', "don't use spaces to indent"),
224 (r'\S\t', "don't use tabs except for indent"),
225 (r'\S\t', "don't use tabs except for indent"),
225 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
226 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
226 (r'.{85}', "line too long"),
227 (r'.{85}', "line too long"),
227 (r'(while|if|do|for)\(', "use space after while/if/do/for"),
228 (r'(while|if|do|for)\(', "use space after while/if/do/for"),
228 (r'return\(', "return is not a function"),
229 (r'return\(', "return is not a function"),
229 (r' ;', "no space before ;"),
230 (r' ;', "no space before ;"),
230 (r'\w+\* \w+', "use int *foo, not int* foo"),
231 (r'\w+\* \w+', "use int *foo, not int* foo"),
231 (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"),
232 (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"),
232 (r'\w+ (\+\+|--)', "use foo++, not foo ++"),
233 (r'\w+ (\+\+|--)', "use foo++, not foo ++"),
233 (r'\w,\w', "missing whitespace after ,"),
234 (r'\w,\w', "missing whitespace after ,"),
234 (r'^[^#]\w[+/*]\w', "missing whitespace in expression"),
235 (r'^[^#]\w[+/*]\w', "missing whitespace in expression"),
235 (r'^#\s+\w', "use #foo, not # foo"),
236 (r'^#\s+\w', "use #foo, not # foo"),
236 (r'[^\n]\Z', "no trailing newline"),
237 (r'[^\n]\Z', "no trailing newline"),
237 (r'^\s*#import\b', "use only #include in standard C code"),
238 (r'^\s*#import\b', "use only #include in standard C code"),
238 ],
239 ],
239 # warnings
240 # warnings
240 []
241 []
241 ]
242 ]
242
243
243 cfilters = [
244 cfilters = [
244 (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment),
245 (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment),
245 (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote),
246 (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote),
246 (r'''(#\s*include\s+<)([^>]+)>''', repinclude),
247 (r'''(#\s*include\s+<)([^>]+)>''', repinclude),
247 (r'(\()([^)]+\))', repcallspaces),
248 (r'(\()([^)]+\))', repcallspaces),
248 ]
249 ]
249
250
250 inutilpats = [
251 inutilpats = [
251 [
252 [
252 (r'\bui\.', "don't use ui in util"),
253 (r'\bui\.', "don't use ui in util"),
253 ],
254 ],
254 # warnings
255 # warnings
255 []
256 []
256 ]
257 ]
257
258
258 inrevlogpats = [
259 inrevlogpats = [
259 [
260 [
260 (r'\brepo\.', "don't use repo in revlog"),
261 (r'\brepo\.', "don't use repo in revlog"),
261 ],
262 ],
262 # warnings
263 # warnings
263 []
264 []
264 ]
265 ]
265
266
266 checks = [
267 checks = [
267 ('python', r'.*\.(py|cgi)$', pyfilters, pypats),
268 ('python', r'.*\.(py|cgi)$', pyfilters, pypats),
268 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats),
269 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats),
269 ('c', r'.*\.c$', cfilters, cpats),
270 ('c', r'.*\.c$', cfilters, cpats),
270 ('unified test', r'.*\.t$', utestfilters, utestpats),
271 ('unified test', r'.*\.t$', utestfilters, utestpats),
271 ('layering violation repo in revlog', r'mercurial/revlog\.py', pyfilters,
272 ('layering violation repo in revlog', r'mercurial/revlog\.py', pyfilters,
272 inrevlogpats),
273 inrevlogpats),
273 ('layering violation ui in util', r'mercurial/util\.py', pyfilters,
274 ('layering violation ui in util', r'mercurial/util\.py', pyfilters,
274 inutilpats),
275 inutilpats),
275 ]
276 ]
276
277
277 class norepeatlogger(object):
278 class norepeatlogger(object):
278 def __init__(self):
279 def __init__(self):
279 self._lastseen = None
280 self._lastseen = None
280
281
281 def log(self, fname, lineno, line, msg, blame):
282 def log(self, fname, lineno, line, msg, blame):
282 """print error related a to given line of a given file.
283 """print error related a to given line of a given file.
283
284
284 The faulty line will also be printed but only once in the case
285 The faulty line will also be printed but only once in the case
285 of multiple errors.
286 of multiple errors.
286
287
287 :fname: filename
288 :fname: filename
288 :lineno: line number
289 :lineno: line number
289 :line: actual content of the line
290 :line: actual content of the line
290 :msg: error message
291 :msg: error message
291 """
292 """
292 msgid = fname, lineno, line
293 msgid = fname, lineno, line
293 if msgid != self._lastseen:
294 if msgid != self._lastseen:
294 if blame:
295 if blame:
295 print "%s:%d (%s):" % (fname, lineno, blame)
296 print "%s:%d (%s):" % (fname, lineno, blame)
296 else:
297 else:
297 print "%s:%d:" % (fname, lineno)
298 print "%s:%d:" % (fname, lineno)
298 print " > %s" % line
299 print " > %s" % line
299 self._lastseen = msgid
300 self._lastseen = msgid
300 print " " + msg
301 print " " + msg
301
302
302 _defaultlogger = norepeatlogger()
303 _defaultlogger = norepeatlogger()
303
304
304 def getblame(f):
305 def getblame(f):
305 lines = []
306 lines = []
306 for l in os.popen('hg annotate -un %s' % f):
307 for l in os.popen('hg annotate -un %s' % f):
307 start, line = l.split(':', 1)
308 start, line = l.split(':', 1)
308 user, rev = start.split()
309 user, rev = start.split()
309 lines.append((line[1:-1], user, rev))
310 lines.append((line[1:-1], user, rev))
310 return lines
311 return lines
311
312
312 def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False,
313 def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False,
313 blame=False, debug=False, lineno=True):
314 blame=False, debug=False, lineno=True):
314 """checks style and portability of a given file
315 """checks style and portability of a given file
315
316
316 :f: filepath
317 :f: filepath
317 :logfunc: function used to report error
318 :logfunc: function used to report error
318 logfunc(filename, linenumber, linecontent, errormessage)
319 logfunc(filename, linenumber, linecontent, errormessage)
319 :maxerr: number of error to display before arborting.
320 :maxerr: number of error to display before arborting.
320 Set to false (default) to report all errors
321 Set to false (default) to report all errors
321
322
322 return True if no error is found, False otherwise.
323 return True if no error is found, False otherwise.
323 """
324 """
324 blamecache = None
325 blamecache = None
325 result = True
326 result = True
326 for name, match, filters, pats in checks:
327 for name, match, filters, pats in checks:
327 if debug:
328 if debug:
328 print name, f
329 print name, f
329 fc = 0
330 fc = 0
330 if not re.match(match, f):
331 if not re.match(match, f):
331 if debug:
332 if debug:
332 print "Skipping %s for %s it doesn't match %s" % (
333 print "Skipping %s for %s it doesn't match %s" % (
333 name, match, f)
334 name, match, f)
334 continue
335 continue
335 fp = open(f)
336 fp = open(f)
336 pre = post = fp.read()
337 pre = post = fp.read()
337 fp.close()
338 fp.close()
338 if "no-" + "check-code" in pre:
339 if "no-" + "check-code" in pre:
339 if debug:
340 if debug:
340 print "Skipping %s for %s it has no- and check-code" % (
341 print "Skipping %s for %s it has no- and check-code" % (
341 name, f)
342 name, f)
342 break
343 break
343 for p, r in filters:
344 for p, r in filters:
344 post = re.sub(p, r, post)
345 post = re.sub(p, r, post)
345 if warnings:
346 if warnings:
346 pats = pats[0] + pats[1]
347 pats = pats[0] + pats[1]
347 else:
348 else:
348 pats = pats[0]
349 pats = pats[0]
349 # print post # uncomment to show filtered version
350 # print post # uncomment to show filtered version
350
351
351 if debug:
352 if debug:
352 print "Checking %s for %s" % (name, f)
353 print "Checking %s for %s" % (name, f)
353
354
354 prelines = None
355 prelines = None
355 errors = []
356 errors = []
356 for p, msg in pats:
357 for p, msg in pats:
357 # fix-up regexes for multiline searches
358 # fix-up regexes for multiline searches
358 po = p
359 po = p
359 # \s doesn't match \n
360 # \s doesn't match \n
360 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
361 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
361 # [^...] doesn't match newline
362 # [^...] doesn't match newline
362 p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
363 p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
363
364
364 #print po, '=>', p
365 #print po, '=>', p
365
366
366 pos = 0
367 pos = 0
367 n = 0
368 n = 0
368 for m in re.finditer(p, post, re.MULTILINE):
369 for m in re.finditer(p, post, re.MULTILINE):
369 if prelines is None:
370 if prelines is None:
370 prelines = pre.splitlines()
371 prelines = pre.splitlines()
371 postlines = post.splitlines(True)
372 postlines = post.splitlines(True)
372
373
373 start = m.start()
374 start = m.start()
374 while n < len(postlines):
375 while n < len(postlines):
375 step = len(postlines[n])
376 step = len(postlines[n])
376 if pos + step > start:
377 if pos + step > start:
377 break
378 break
378 pos += step
379 pos += step
379 n += 1
380 n += 1
380 l = prelines[n]
381 l = prelines[n]
381
382
382 if "check-code" + "-ignore" in l:
383 if "check-code" + "-ignore" in l:
383 if debug:
384 if debug:
384 print "Skipping %s for %s:%s (check-code -ignore)" % (
385 print "Skipping %s for %s:%s (check-code -ignore)" % (
385 name, f, n)
386 name, f, n)
386 continue
387 continue
387 bd = ""
388 bd = ""
388 if blame:
389 if blame:
389 bd = 'working directory'
390 bd = 'working directory'
390 if not blamecache:
391 if not blamecache:
391 blamecache = getblame(f)
392 blamecache = getblame(f)
392 if n < len(blamecache):
393 if n < len(blamecache):
393 bl, bu, br = blamecache[n]
394 bl, bu, br = blamecache[n]
394 if bl == l:
395 if bl == l:
395 bd = '%s@%s' % (bu, br)
396 bd = '%s@%s' % (bu, br)
396 errors.append((f, lineno and n + 1, l, msg, bd))
397 errors.append((f, lineno and n + 1, l, msg, bd))
397 result = False
398 result = False
398
399
399 errors.sort()
400 errors.sort()
400 for e in errors:
401 for e in errors:
401 logfunc(*e)
402 logfunc(*e)
402 fc += 1
403 fc += 1
403 if maxerr and fc >= maxerr:
404 if maxerr and fc >= maxerr:
404 print " (too many errors, giving up)"
405 print " (too many errors, giving up)"
405 break
406 break
406
407
407 return result
408 return result
408
409
409 if __name__ == "__main__":
410 if __name__ == "__main__":
410 parser = optparse.OptionParser("%prog [options] [files]")
411 parser = optparse.OptionParser("%prog [options] [files]")
411 parser.add_option("-w", "--warnings", action="store_true",
412 parser.add_option("-w", "--warnings", action="store_true",
412 help="include warning-level checks")
413 help="include warning-level checks")
413 parser.add_option("-p", "--per-file", type="int",
414 parser.add_option("-p", "--per-file", type="int",
414 help="max warnings per file")
415 help="max warnings per file")
415 parser.add_option("-b", "--blame", action="store_true",
416 parser.add_option("-b", "--blame", action="store_true",
416 help="use annotate to generate blame info")
417 help="use annotate to generate blame info")
417 parser.add_option("", "--debug", action="store_true",
418 parser.add_option("", "--debug", action="store_true",
418 help="show debug information")
419 help="show debug information")
419 parser.add_option("", "--nolineno", action="store_false",
420 parser.add_option("", "--nolineno", action="store_false",
420 dest='lineno', help="don't show line numbers")
421 dest='lineno', help="don't show line numbers")
421
422
422 parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False,
423 parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False,
423 lineno=True)
424 lineno=True)
424 (options, args) = parser.parse_args()
425 (options, args) = parser.parse_args()
425
426
426 if len(args) == 0:
427 if len(args) == 0:
427 check = glob.glob("*")
428 check = glob.glob("*")
428 else:
429 else:
429 check = args
430 check = args
430
431
431 ret = 0
432 ret = 0
432 for f in check:
433 for f in check:
433 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
434 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
434 blame=options.blame, debug=options.debug,
435 blame=options.blame, debug=options.debug,
435 lineno=options.lineno):
436 lineno=options.lineno):
436 ret = 1
437 ret = 1
437 sys.exit(ret)
438 sys.exit(ret)
@@ -1,633 +1,646
1 $ check_code="$TESTDIR"/../contrib/check-code.py
1 $ check_code="$TESTDIR"/../contrib/check-code.py
2 $ cd "$TESTDIR"/..
2 $ cd "$TESTDIR"/..
3 $ if hg identify -q > /dev/null; then :
3 $ if hg identify -q > /dev/null; then :
4 > else
4 > else
5 > echo "skipped: not a Mercurial working dir" >&2
5 > echo "skipped: not a Mercurial working dir" >&2
6 > exit 80
6 > exit 80
7 > fi
7 > fi
8 $ hg manifest | xargs "$check_code" || echo 'FAILURE IS NOT AN OPTION!!!'
8 $ hg manifest | xargs "$check_code" || echo 'FAILURE IS NOT AN OPTION!!!'
9
9
10 $ hg manifest | xargs "$check_code" --warnings --nolineno --per-file=0 || true
10 $ hg manifest | xargs "$check_code" --warnings --nolineno --per-file=0 || true
11 contrib/check-code.py:0:
11 contrib/check-code.py:0:
12 > # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"),
12 > # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"),
13 warning: line over 80 characters
13 warning: line over 80 characters
14 contrib/perf.py:0:
14 contrib/perf.py:0:
15 > except:
15 > except:
16 warning: naked except clause
16 warning: naked except clause
17 contrib/perf.py:0:
17 contrib/perf.py:0:
18 > #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, False))))
18 > #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, False))))
19 warning: line over 80 characters
19 warning: line over 80 characters
20 contrib/perf.py:0:
20 contrib/perf.py:0:
21 > except:
21 > except:
22 warning: naked except clause
22 warning: naked except clause
23 contrib/setup3k.py:0:
23 contrib/setup3k.py:0:
24 > except:
24 > except:
25 warning: naked except clause
25 warning: naked except clause
26 contrib/setup3k.py:0:
26 contrib/setup3k.py:0:
27 > except:
27 > except:
28 warning: naked except clause
28 warning: naked except clause
29 contrib/setup3k.py:0:
29 contrib/setup3k.py:0:
30 > except:
30 > except:
31 warning: naked except clause
31 warning: naked except clause
32 warning: naked except clause
32 warning: naked except clause
33 warning: naked except clause
33 warning: naked except clause
34 contrib/shrink-revlog.py:0:
34 contrib/shrink-revlog.py:0:
35 > except:
35 > except:
36 warning: naked except clause
36 warning: naked except clause
37 doc/gendoc.py:0:
37 doc/gendoc.py:0:
38 > "together with Mercurial. Help for other extensions is available "
38 > "together with Mercurial. Help for other extensions is available "
39 warning: line over 80 characters
39 warning: line over 80 characters
40 hgext/bugzilla.py:0:
40 hgext/bugzilla.py:0:
41 > raise util.Abort(_('cannot find bugzilla user id for %s or %s') %
41 > raise util.Abort(_('cannot find bugzilla user id for %s or %s') %
42 warning: line over 80 characters
42 warning: line over 80 characters
43 hgext/bugzilla.py:0:
43 hgext/bugzilla.py:0:
44 > bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla')
44 > bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla')
45 warning: line over 80 characters
45 warning: line over 80 characters
46 hgext/convert/__init__.py:0:
46 hgext/convert/__init__.py:0:
47 > ('', 'ancestors', '', _('show current changeset in ancestor branches')),
47 > ('', 'ancestors', '', _('show current changeset in ancestor branches')),
48 warning: line over 80 characters
48 warning: line over 80 characters
49 hgext/convert/bzr.py:0:
49 hgext/convert/bzr.py:0:
50 > except:
50 > except:
51 warning: naked except clause
51 warning: naked except clause
52 hgext/convert/common.py:0:
52 hgext/convert/common.py:0:
53 > except:
53 > except:
54 warning: naked except clause
54 warning: naked except clause
55 hgext/convert/common.py:0:
55 hgext/convert/common.py:0:
56 > except:
56 > except:
57 warning: naked except clause
57 warning: naked except clause
58 warning: naked except clause
58 warning: naked except clause
59 hgext/convert/convcmd.py:0:
59 hgext/convert/convcmd.py:0:
60 > except:
60 > except:
61 warning: naked except clause
61 warning: naked except clause
62 hgext/convert/cvs.py:0:
62 hgext/convert/cvs.py:0:
63 > # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z
63 > # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z
64 warning: line over 80 characters
64 warning: line over 80 characters
65 hgext/convert/cvsps.py:0:
65 hgext/convert/cvsps.py:0:
66 > assert len(branches) == 1, 'unknown branch: %s' % e.mergepoint
66 > assert len(branches) == 1, 'unknown branch: %s' % e.mergepoint
67 warning: line over 80 characters
67 warning: line over 80 characters
68 hgext/convert/cvsps.py:0:
68 hgext/convert/cvsps.py:0:
69 > ui.write('Ancestors: %s\n' % (','.join(r)))
69 > ui.write('Ancestors: %s\n' % (','.join(r)))
70 warning: unwrapped ui message
70 warning: unwrapped ui message
71 hgext/convert/cvsps.py:0:
71 hgext/convert/cvsps.py:0:
72 > ui.write('Parent: %d\n' % cs.parents[0].id)
72 > ui.write('Parent: %d\n' % cs.parents[0].id)
73 warning: unwrapped ui message
73 warning: unwrapped ui message
74 hgext/convert/cvsps.py:0:
74 hgext/convert/cvsps.py:0:
75 > ui.write('Parents: %s\n' %
75 > ui.write('Parents: %s\n' %
76 warning: unwrapped ui message
76 warning: unwrapped ui message
77 hgext/convert/cvsps.py:0:
77 hgext/convert/cvsps.py:0:
78 > except:
78 > except:
79 warning: naked except clause
79 warning: naked except clause
80 hgext/convert/cvsps.py:0:
80 hgext/convert/cvsps.py:0:
81 > ui.write('Branchpoints: %s \n' % ', '.join(branchpoints))
81 > ui.write('Branchpoints: %s \n' % ', '.join(branchpoints))
82 warning: unwrapped ui message
82 warning: unwrapped ui message
83 hgext/convert/cvsps.py:0:
83 hgext/convert/cvsps.py:0:
84 > ui.write('Author: %s\n' % cs.author)
84 > ui.write('Author: %s\n' % cs.author)
85 warning: unwrapped ui message
85 warning: unwrapped ui message
86 hgext/convert/cvsps.py:0:
86 hgext/convert/cvsps.py:0:
87 > ui.write('Branch: %s\n' % (cs.branch or 'HEAD'))
87 > ui.write('Branch: %s\n' % (cs.branch or 'HEAD'))
88 warning: unwrapped ui message
88 warning: unwrapped ui message
89 hgext/convert/cvsps.py:0:
89 hgext/convert/cvsps.py:0:
90 > ui.write('Date: %s\n' % util.datestr(cs.date,
90 > ui.write('Date: %s\n' % util.datestr(cs.date,
91 warning: unwrapped ui message
91 warning: unwrapped ui message
92 hgext/convert/cvsps.py:0:
92 hgext/convert/cvsps.py:0:
93 > ui.write('Log:\n')
93 > ui.write('Log:\n')
94 warning: unwrapped ui message
94 warning: unwrapped ui message
95 hgext/convert/cvsps.py:0:
95 hgext/convert/cvsps.py:0:
96 > ui.write('Members: \n')
96 > ui.write('Members: \n')
97 warning: unwrapped ui message
97 warning: unwrapped ui message
98 hgext/convert/cvsps.py:0:
98 hgext/convert/cvsps.py:0:
99 > ui.write('PatchSet %d \n' % cs.id)
99 > ui.write('PatchSet %d \n' % cs.id)
100 warning: unwrapped ui message
100 warning: unwrapped ui message
101 hgext/convert/cvsps.py:0:
101 hgext/convert/cvsps.py:0:
102 > ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1],
102 > ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1],
103 warning: unwrapped ui message
103 warning: unwrapped ui message
104 hgext/convert/git.py:0:
104 hgext/convert/git.py:0:
105 > except:
105 > except:
106 warning: naked except clause
106 warning: naked except clause
107 hgext/convert/git.py:0:
107 hgext/convert/git.py:0:
108 > fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --'
108 > fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --'
109 warning: line over 80 characters
109 warning: line over 80 characters
110 hgext/convert/hg.py:0:
110 hgext/convert/hg.py:0:
111 > # detect missing revlogs and abort on errors or populate self.ignored
111 > # detect missing revlogs and abort on errors or populate self.ignored
112 warning: line over 80 characters
112 warning: line over 80 characters
113 hgext/convert/hg.py:0:
113 hgext/convert/hg.py:0:
114 > except:
114 > except:
115 warning: naked except clause
115 warning: naked except clause
116 warning: naked except clause
116 warning: naked except clause
117 hgext/convert/hg.py:0:
117 hgext/convert/hg.py:0:
118 > except:
118 > except:
119 warning: naked except clause
119 warning: naked except clause
120 hgext/convert/monotone.py:0:
120 hgext/convert/monotone.py:0:
121 > except:
121 > except:
122 warning: naked except clause
122 warning: naked except clause
123 hgext/convert/monotone.py:0:
123 hgext/convert/monotone.py:0:
124 > except:
124 > except:
125 warning: naked except clause
125 warning: naked except clause
126 hgext/convert/subversion.py:0:
126 hgext/convert/subversion.py:0:
127 > raise util.Abort(_('svn: branch has no revision %s') % to_revnum)
127 > raise util.Abort(_('svn: branch has no revision %s') % to_revnum)
128 warning: line over 80 characters
128 warning: line over 80 characters
129 hgext/convert/subversion.py:0:
129 hgext/convert/subversion.py:0:
130 > except:
130 > except:
131 warning: naked except clause
131 warning: naked except clause
132 hgext/convert/subversion.py:0:
132 hgext/convert/subversion.py:0:
133 > args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths,
133 > args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths,
134 warning: line over 80 characters
134 warning: line over 80 characters
135 hgext/convert/subversion.py:0:
135 hgext/convert/subversion.py:0:
136 > self.trunkname = self.ui.config('convert', 'svn.trunk', 'trunk').strip('/')
136 > self.trunkname = self.ui.config('convert', 'svn.trunk', 'trunk').strip('/')
137 warning: line over 80 characters
137 warning: line over 80 characters
138 hgext/convert/subversion.py:0:
138 hgext/convert/subversion.py:0:
139 > except:
139 > except:
140 warning: naked except clause
140 warning: naked except clause
141 hgext/convert/subversion.py:0:
141 hgext/convert/subversion.py:0:
142 > def get_log_child(fp, url, paths, start, end, limit=0, discover_changed_paths=True,
142 > def get_log_child(fp, url, paths, start, end, limit=0, discover_changed_paths=True,
143 warning: line over 80 characters
143 warning: line over 80 characters
144 hgext/eol.py:0:
144 hgext/eol.py:0:
145 > if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
145 > if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n':
146 warning: line over 80 characters
146 warning: line over 80 characters
147 warning: line over 80 characters
147 warning: line over 80 characters
148 hgext/gpg.py:0:
148 hgext/gpg.py:0:
149 > except:
149 > except:
150 warning: naked except clause
150 warning: naked except clause
151 hgext/hgcia.py:0:
151 hgext/hgcia.py:0:
152 > except:
152 > except:
153 warning: naked except clause
153 warning: naked except clause
154 hgext/hgk.py:0:
154 hgext/hgk.py:0:
155 > ui.write("%s%s\n" % (prefix, description.replace('\n', nlprefix).strip()))
155 > ui.write("%s%s\n" % (prefix, description.replace('\n', nlprefix).strip()))
156 warning: line over 80 characters
156 warning: line over 80 characters
157 hgext/hgk.py:0:
157 hgext/hgk.py:0:
158 > ui.write("parent %s\n" % p)
158 > ui.write("parent %s\n" % p)
159 warning: unwrapped ui message
159 warning: unwrapped ui message
160 hgext/hgk.py:0:
160 hgext/hgk.py:0:
161 > ui.write('k=%s\nv=%s\n' % (name, value))
161 > ui.write('k=%s\nv=%s\n' % (name, value))
162 warning: unwrapped ui message
162 warning: unwrapped ui message
163 hgext/hgk.py:0:
163 hgext/hgk.py:0:
164 > ui.write("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1]))
164 > ui.write("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1]))
165 warning: unwrapped ui message
165 warning: unwrapped ui message
166 hgext/hgk.py:0:
166 hgext/hgk.py:0:
167 > ui.write("branch %s\n\n" % ctx.branch())
167 > ui.write("branch %s\n\n" % ctx.branch())
168 warning: unwrapped ui message
168 warning: unwrapped ui message
169 hgext/hgk.py:0:
169 hgext/hgk.py:0:
170 > ui.write("committer %s %s %s\n" % (committer, int(date[0]), date[1]))
170 > ui.write("committer %s %s %s\n" % (committer, int(date[0]), date[1]))
171 warning: unwrapped ui message
171 warning: unwrapped ui message
172 hgext/hgk.py:0:
172 hgext/hgk.py:0:
173 > ui.write("revision %d\n" % ctx.rev())
173 > ui.write("revision %d\n" % ctx.rev())
174 warning: unwrapped ui message
174 warning: unwrapped ui message
175 hgext/hgk.py:0:
175 hgext/hgk.py:0:
176 > ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ??
176 > ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ??
177 warning: line over 80 characters
177 warning: line over 80 characters
178 warning: unwrapped ui message
178 warning: unwrapped ui message
179 hgext/highlight/__init__.py:0:
179 hgext/highlight/__init__.py:0:
180 > extensions.wrapfunction(webcommands, '_filerevision', filerevision_highlight)
180 > extensions.wrapfunction(webcommands, '_filerevision', filerevision_highlight)
181 warning: line over 80 characters
181 warning: line over 80 characters
182 hgext/highlight/__init__.py:0:
182 hgext/highlight/__init__.py:0:
183 > return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')]
183 > return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')]
184 warning: line over 80 characters
184 warning: line over 80 characters
185 hgext/inotify/__init__.py:0:
185 hgext/inotify/__init__.py:0:
186 > if self._inotifyon and not ignored and not subrepos and not self._dirty:
186 > if self._inotifyon and not ignored and not subrepos and not self._dirty:
187 warning: line over 80 characters
187 warning: line over 80 characters
188 hgext/inotify/server.py:0:
188 hgext/inotify/server.py:0:
189 > except:
189 > except:
190 warning: naked except clause
190 warning: naked except clause
191 hgext/inotify/server.py:0:
191 hgext/inotify/server.py:0:
192 > except:
192 > except:
193 warning: naked except clause
193 warning: naked except clause
194 hgext/keyword.py:0:
194 hgext/keyword.py:0:
195 > ui.note("hg ci -m '%s'\n" % msg)
195 > ui.note("hg ci -m '%s'\n" % msg)
196 warning: unwrapped ui message
196 warning: unwrapped ui message
197 hgext/mq.py:0:
197 hgext/mq.py:0:
198 > raise util.Abort(_("cannot push --exact with applied patches"))
198 > raise util.Abort(_("cannot push --exact with applied patches"))
199 warning: line over 80 characters
199 warning: line over 80 characters
200 hgext/mq.py:0:
200 hgext/mq.py:0:
201 > raise util.Abort(_("cannot use --exact and --move together"))
201 > raise util.Abort(_("cannot use --exact and --move together"))
202 warning: line over 80 characters
202 warning: line over 80 characters
203 hgext/mq.py:0:
203 hgext/mq.py:0:
204 > self.ui.warn(_('Tag %s overrides mq patch of the same name\n')
204 > self.ui.warn(_('Tag %s overrides mq patch of the same name\n')
205 warning: line over 80 characters
205 warning: line over 80 characters
206 hgext/mq.py:0:
206 hgext/mq.py:0:
207 > except:
207 > except:
208 warning: naked except clause
208 warning: naked except clause
209 warning: naked except clause
209 warning: naked except clause
210 hgext/mq.py:0:
210 hgext/mq.py:0:
211 > except:
211 > except:
212 warning: naked except clause
212 warning: naked except clause
213 warning: naked except clause
213 warning: naked except clause
214 warning: naked except clause
214 warning: naked except clause
215 warning: naked except clause
215 warning: naked except clause
216 hgext/mq.py:0:
216 hgext/mq.py:0:
217 > raise util.Abort(_('cannot mix -l/--list with options or arguments'))
217 > raise util.Abort(_('cannot mix -l/--list with options or arguments'))
218 warning: line over 80 characters
218 warning: line over 80 characters
219 hgext/mq.py:0:
219 hgext/mq.py:0:
220 > raise util.Abort(_('qfold cannot fold already applied patch %s') % p)
220 > raise util.Abort(_('qfold cannot fold already applied patch %s') % p)
221 warning: line over 80 characters
221 warning: line over 80 characters
222 hgext/mq.py:0:
222 hgext/mq.py:0:
223 > ('', 'move', None, _('reorder patch series and apply only the patch'))],
223 > ('', 'move', None, _('reorder patch series and apply only the patch'))],
224 warning: line over 80 characters
224 warning: line over 80 characters
225 hgext/mq.py:0:
225 hgext/mq.py:0:
226 > ('U', 'noupdate', None, _('do not update the new working directories')),
226 > ('U', 'noupdate', None, _('do not update the new working directories')),
227 warning: line over 80 characters
227 warning: line over 80 characters
228 hgext/mq.py:0:
228 hgext/mq.py:0:
229 > ('e', 'exact', None, _('apply the target patch to its recorded parent')),
229 > ('e', 'exact', None, _('apply the target patch to its recorded parent')),
230 warning: line over 80 characters
230 warning: line over 80 characters
231 hgext/mq.py:0:
231 hgext/mq.py:0:
232 > except:
232 > except:
233 warning: naked except clause
233 warning: naked except clause
234 hgext/mq.py:0:
234 hgext/mq.py:0:
235 > ui.write("mq: %s\n" % ', '.join(m))
235 > ui.write("mq: %s\n" % ', '.join(m))
236 warning: unwrapped ui message
236 warning: unwrapped ui message
237 hgext/mq.py:0:
237 hgext/mq.py:0:
238 > repo.mq.qseries(repo, missing=opts.get('missing'), summary=opts.get('summary'))
238 > repo.mq.qseries(repo, missing=opts.get('missing'), summary=opts.get('summary'))
239 warning: line over 80 characters
239 warning: line over 80 characters
240 hgext/notify.py:0:
240 hgext/notify.py:0:
241 > ui.note(_('notify: suppressing notification for merge %d:%s\n') %
241 > ui.note(_('notify: suppressing notification for merge %d:%s\n') %
242 warning: line over 80 characters
242 warning: line over 80 characters
243 hgext/patchbomb.py:0:
243 hgext/patchbomb.py:0:
244 > binnode, seqno=idx, total=total)
244 > binnode, seqno=idx, total=total)
245 warning: line over 80 characters
245 warning: line over 80 characters
246 hgext/patchbomb.py:0:
246 hgext/patchbomb.py:0:
247 > except:
247 > except:
248 warning: naked except clause
248 warning: naked except clause
249 hgext/patchbomb.py:0:
249 hgext/patchbomb.py:0:
250 > ui.write('Subject: %s\n' % subj)
250 > ui.write('Subject: %s\n' % subj)
251 warning: unwrapped ui message
251 warning: unwrapped ui message
252 hgext/patchbomb.py:0:
252 hgext/patchbomb.py:0:
253 > p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch', opts.get('test'))
253 > p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch', opts.get('test'))
254 warning: line over 80 characters
254 warning: line over 80 characters
255 hgext/patchbomb.py:0:
255 hgext/patchbomb.py:0:
256 > ui.write('From: %s\n' % sender)
256 > ui.write('From: %s\n' % sender)
257 warning: unwrapped ui message
257 warning: unwrapped ui message
258 hgext/record.py:0:
258 hgext/record.py:0:
259 > ignoreblanklines=opts.get('ignore_blank_lines'))
259 > ignoreblanklines=opts.get('ignore_blank_lines'))
260 warning: line over 80 characters
260 warning: line over 80 characters
261 hgext/record.py:0:
261 hgext/record.py:0:
262 > ignorewsamount=opts.get('ignore_space_change'),
262 > ignorewsamount=opts.get('ignore_space_change'),
263 warning: line over 80 characters
263 warning: line over 80 characters
264 hgext/zeroconf/__init__.py:0:
264 hgext/zeroconf/__init__.py:0:
265 > publish(name, desc, path, util.getport(u.config("web", "port", 8000)))
265 > publish(name, desc, path, util.getport(u.config("web", "port", 8000)))
266 warning: line over 80 characters
266 warning: line over 80 characters
267 hgext/zeroconf/__init__.py:0:
267 hgext/zeroconf/__init__.py:0:
268 > except:
268 > except:
269 warning: naked except clause
269 warning: naked except clause
270 warning: naked except clause
270 warning: naked except clause
271 mercurial/bundlerepo.py:0:
271 mercurial/bundlerepo.py:0:
272 > is a bundlerepo for the obtained bundle when the original "other" is remote.
272 > is a bundlerepo for the obtained bundle when the original "other" is remote.
273 warning: line over 80 characters
273 warning: line over 80 characters
274 mercurial/bundlerepo.py:0:
274 mercurial/bundlerepo.py:0:
275 > "local" is a local repo from which to obtain the actual incoming changesets; it
275 > "local" is a local repo from which to obtain the actual incoming changesets; it
276 warning: line over 80 characters
276 warning: line over 80 characters
277 mercurial/bundlerepo.py:0:
277 mercurial/bundlerepo.py:0:
278 > tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, force=force)
278 > tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, force=force)
279 warning: line over 80 characters
279 warning: line over 80 characters
280 mercurial/commands.py:0:
280 mercurial/commands.py:0:
281 > " size " + basehdr + " link p1 p2 nodeid\n")
281 > " size " + basehdr + " link p1 p2 nodeid\n")
282 warning: line over 80 characters
282 warning: line over 80 characters
283 mercurial/commands.py:0:
283 mercurial/commands.py:0:
284 > raise util.Abort('cannot use localheads with old style discovery')
284 > raise util.Abort('cannot use localheads with old style discovery')
285 warning: line over 80 characters
285 warning: line over 80 characters
286 mercurial/commands.py:0:
286 mercurial/commands.py:0:
287 > ui.note('branch %s\n' % data)
287 > ui.note('branch %s\n' % data)
288 warning: unwrapped ui message
288 warning: unwrapped ui message
289 mercurial/commands.py:0:
289 mercurial/commands.py:0:
290 > ui.note('node %s\n' % str(data))
290 > ui.note('node %s\n' % str(data))
291 warning: unwrapped ui message
291 warning: unwrapped ui message
292 mercurial/commands.py:0:
292 mercurial/commands.py:0:
293 > ui.note('tag %s\n' % name)
293 > ui.note('tag %s\n' % name)
294 warning: unwrapped ui message
294 warning: unwrapped ui message
295 mercurial/commands.py:0:
295 mercurial/commands.py:0:
296 > ui.write("unpruned common: %s\n" % " ".join([short(n)
296 > ui.write("unpruned common: %s\n" % " ".join([short(n)
297 warning: unwrapped ui message
297 warning: unwrapped ui message
298 mercurial/commands.py:0:
298 mercurial/commands.py:0:
299 > yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
299 > yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
300 warning: line over 80 characters
300 warning: line over 80 characters
301 mercurial/commands.py:0:
301 mercurial/commands.py:0:
302 > yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
302 > yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
303 warning: line over 80 characters
303 warning: line over 80 characters
304 mercurial/commands.py:0:
304 mercurial/commands.py:0:
305 > except:
305 > except:
306 warning: naked except clause
306 warning: naked except clause
307 mercurial/commands.py:0:
307 mercurial/commands.py:0:
308 > ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n"))
308 > ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n"))
309 warning: line over 80 characters
309 warning: line over 80 characters
310 mercurial/commands.py:0:
310 mercurial/commands.py:0:
311 > ui.write("format: id, p1, p2, cset, delta base, len(delta)\n")
311 > ui.write("format: id, p1, p2, cset, delta base, len(delta)\n")
312 warning: unwrapped ui message
312 warning: unwrapped ui message
313 mercurial/commands.py:0:
313 mercurial/commands.py:0:
314 > ui.write("local is subset\n")
314 > ui.write("local is subset\n")
315 warning: unwrapped ui message
315 warning: unwrapped ui message
316 mercurial/commands.py:0:
316 mercurial/commands.py:0:
317 > ui.write("remote is subset\n")
317 > ui.write("remote is subset\n")
318 warning: unwrapped ui message
318 warning: unwrapped ui message
319 mercurial/commands.py:0:
319 mercurial/commands.py:0:
320 > ui.write(' other : ' + fmt2 % pcfmt(numoprev, numprev))
320 > ui.write(' other : ' + fmt2 % pcfmt(numoprev, numprev))
321 warning: line over 80 characters
321 warning: line over 80 characters
322 mercurial/commands.py:0:
322 mercurial/commands.py:0:
323 > ui.write(' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev))
323 > ui.write(' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev))
324 warning: line over 80 characters
324 warning: line over 80 characters
325 mercurial/commands.py:0:
325 mercurial/commands.py:0:
326 > ui.write(' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev))
326 > ui.write(' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev))
327 warning: line over 80 characters
327 warning: line over 80 characters
328 mercurial/commands.py:0:
328 mercurial/commands.py:0:
329 > ui.write('deltas against other : ' + fmt % pcfmt(numother, numdeltas))
329 > ui.write('deltas against other : ' + fmt % pcfmt(numother, numdeltas))
330 warning: line over 80 characters
330 warning: line over 80 characters
331 warning: unwrapped ui message
331 warning: unwrapped ui message
332 mercurial/commands.py:0:
332 mercurial/commands.py:0:
333 > ui.write('deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas))
333 > ui.write('deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas))
334 warning: unwrapped ui message
334 warning: unwrapped ui message
335 mercurial/commands.py:0:
335 mercurial/commands.py:0:
336 > ui.write('deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas))
336 > ui.write('deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas))
337 warning: unwrapped ui message
337 warning: unwrapped ui message
338 mercurial/commands.py:0:
338 mercurial/commands.py:0:
339 > except:
339 > except:
340 warning: naked except clause
340 warning: naked except clause
341 mercurial/commands.py:0:
341 mercurial/commands.py:0:
342 > revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
342 > revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
343 warning: line over 80 characters
343 warning: line over 80 characters
344 mercurial/commands.py:0:
344 mercurial/commands.py:0:
345 > ui.write("common heads: %s\n" % " ".join([short(n) for n in common]))
345 > ui.write("common heads: %s\n" % " ".join([short(n) for n in common]))
346 warning: unwrapped ui message
346 warning: unwrapped ui message
347 mercurial/commands.py:0:
347 mercurial/commands.py:0:
348 > ui.write("match: %s\n" % m(d[0]))
348 > ui.write("match: %s\n" % m(d[0]))
349 warning: unwrapped ui message
349 warning: unwrapped ui message
350 mercurial/commands.py:0:
350 mercurial/commands.py:0:
351 > ui.write('deltas against prev : ' + fmt % pcfmt(numprev, numdeltas))
351 > ui.write('deltas against prev : ' + fmt % pcfmt(numprev, numdeltas))
352 warning: unwrapped ui message
352 warning: unwrapped ui message
353 mercurial/commands.py:0:
353 mercurial/commands.py:0:
354 > ui.write('path %s\n' % k)
354 > ui.write('path %s\n' % k)
355 warning: unwrapped ui message
355 warning: unwrapped ui message
356 mercurial/commands.py:0:
356 mercurial/commands.py:0:
357 > ui.write('uncompressed data size (min/max/avg) : %d / %d / %d\n'
357 > ui.write('uncompressed data size (min/max/avg) : %d / %d / %d\n'
358 warning: unwrapped ui message
358 warning: unwrapped ui message
359 mercurial/commands.py:0:
359 mercurial/commands.py:0:
360 > Every ID must be a full-length hex node id string. Returns a list of 0s and 1s
360 > Every ID must be a full-length hex node id string. Returns a list of 0s and 1s
361 warning: line over 80 characters
361 warning: line over 80 characters
362 mercurial/commands.py:0:
362 mercurial/commands.py:0:
363 > remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), opts.get('branch'))
363 > remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), opts.get('branch'))
364 warning: line over 80 characters
364 warning: line over 80 characters
365 mercurial/commands.py:0:
365 mercurial/commands.py:0:
366 > ui.write("digraph G {\n")
366 > ui.write("digraph G {\n")
367 warning: unwrapped ui message
367 warning: unwrapped ui message
368 mercurial/commands.py:0:
368 mercurial/commands.py:0:
369 > ui.write("internal: %s %s\n" % d)
369 > ui.write("internal: %s %s\n" % d)
370 warning: unwrapped ui message
370 warning: unwrapped ui message
371 mercurial/commands.py:0:
371 mercurial/commands.py:0:
372 > ui.write("standard: %s\n" % util.datestr(d))
372 > ui.write("standard: %s\n" % util.datestr(d))
373 warning: unwrapped ui message
373 warning: unwrapped ui message
374 mercurial/commands.py:0:
374 mercurial/commands.py:0:
375 > ui.write('avg chain length : ' + fmt % avgchainlen)
375 > ui.write('avg chain length : ' + fmt % avgchainlen)
376 warning: unwrapped ui message
376 warning: unwrapped ui message
377 mercurial/commands.py:0:
377 mercurial/commands.py:0:
378 > ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
378 > ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
379 warning: unwrapped ui message
379 warning: unwrapped ui message
380 mercurial/commands.py:0:
380 mercurial/commands.py:0:
381 > ui.write('compression ratio : ' + fmt % compratio)
381 > ui.write('compression ratio : ' + fmt % compratio)
382 warning: unwrapped ui message
382 warning: unwrapped ui message
383 mercurial/commands.py:0:
383 mercurial/commands.py:0:
384 > ui.write('delta size (min/max/avg) : %d / %d / %d\n'
384 > ui.write('delta size (min/max/avg) : %d / %d / %d\n'
385 warning: unwrapped ui message
385 warning: unwrapped ui message
386 mercurial/commands.py:0:
386 mercurial/commands.py:0:
387 > ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
387 > ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
388 warning: unwrapped ui message
388 warning: unwrapped ui message
389 mercurial/commands.py:0:
389 mercurial/commands.py:0:
390 > ui.write('flags : %s\n' % ', '.join(flags))
390 > ui.write('flags : %s\n' % ', '.join(flags))
391 warning: unwrapped ui message
391 warning: unwrapped ui message
392 mercurial/commands.py:0:
392 mercurial/commands.py:0:
393 > ui.write('format : %d\n' % format)
393 > ui.write('format : %d\n' % format)
394 warning: unwrapped ui message
394 warning: unwrapped ui message
395 mercurial/commands.py:0:
395 mercurial/commands.py:0:
396 > ui.write('full revision size (min/max/avg) : %d / %d / %d\n'
396 > ui.write('full revision size (min/max/avg) : %d / %d / %d\n'
397 warning: unwrapped ui message
397 warning: unwrapped ui message
398 mercurial/commands.py:0:
398 mercurial/commands.py:0:
399 > ui.write('revision size : ' + fmt2 % totalsize)
399 > ui.write('revision size : ' + fmt2 % totalsize)
400 warning: unwrapped ui message
400 warning: unwrapped ui message
401 mercurial/commands.py:0:
401 mercurial/commands.py:0:
402 > ui.write('revisions : ' + fmt2 % numrevs)
402 > ui.write('revisions : ' + fmt2 % numrevs)
403 warning: unwrapped ui message
403 warning: unwrapped ui message
404 warning: unwrapped ui message
404 warning: unwrapped ui message
405 mercurial/commands.py:0:
405 mercurial/commands.py:0:
406 > ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
406 > ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
407 warning: unwrapped ui message
407 warning: unwrapped ui message
408 mercurial/commandserver.py:0:
408 mercurial/commandserver.py:0:
409 > # the ui here is really the repo ui so take its baseui so we don't end up
409 > # the ui here is really the repo ui so take its baseui so we don't end up
410 warning: line over 80 characters
410 warning: line over 80 characters
411 mercurial/context.py:0:
411 mercurial/context.py:0:
412 > return self._manifestdelta[path], self._manifestdelta.flags(path)
412 > return self._manifestdelta[path], self._manifestdelta.flags(path)
413 warning: line over 80 characters
413 warning: line over 80 characters
414 mercurial/dagparser.py:0:
414 mercurial/dagparser.py:0:
415 > raise util.Abort(_("invalid character in dag description: %s...") % s)
415 > raise util.Abort(_("invalid character in dag description: %s...") % s)
416 warning: line over 80 characters
416 warning: line over 80 characters
417 mercurial/dagparser.py:0:
417 mercurial/dagparser.py:0:
418 > >>> dagtext([('n', (0, [-1])), ('C', 'my command line'), ('n', (1, [0]))])
418 > >>> dagtext([('n', (0, [-1])), ('C', 'my command line'), ('n', (1, [0]))])
419 warning: line over 80 characters
419 warning: line over 80 characters
420 mercurial/dirstate.py:0:
420 mercurial/dirstate.py:0:
421 > if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
421 > if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
422 warning: line over 80 characters
422 warning: line over 80 characters
423 mercurial/discovery.py:0:
423 mercurial/discovery.py:0:
424 > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive)
424 > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive)
425 warning: line over 80 characters
425 warning: line over 80 characters
426 mercurial/discovery.py:0:
426 mercurial/discovery.py:0:
427 > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None):
427 > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None):
428 warning: line over 80 characters
428 warning: line over 80 characters
429 mercurial/dispatch.py:0:
429 mercurial/dispatch.py:0:
430 > " (.hg not found)") % os.getcwd())
430 > " (.hg not found)") % os.getcwd())
431 warning: line over 80 characters
431 warning: line over 80 characters
432 mercurial/dispatch.py:0:
432 mercurial/dispatch.py:0:
433 > except:
433 > except:
434 warning: naked except clause
434 warning: naked except clause
435 mercurial/dispatch.py:0:
435 mercurial/dispatch.py:0:
436 > return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {})
436 > return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {})
437 warning: line over 80 characters
437 warning: line over 80 characters
438 mercurial/dispatch.py:0:
438 mercurial/dispatch.py:0:
439 > def __init__(self, args, ui=None, repo=None, fin=None, fout=None, ferr=None):
439 > def __init__(self, args, ui=None, repo=None, fin=None, fout=None, ferr=None):
440 warning: line over 80 characters
440 warning: line over 80 characters
441 mercurial/dispatch.py:0:
441 mercurial/dispatch.py:0:
442 > except:
442 > except:
443 warning: naked except clause
443 warning: naked except clause
444 mercurial/hg.py:0:
444 mercurial/hg.py:0:
445 > except:
445 > except:
446 warning: naked except clause
446 warning: naked except clause
447 mercurial/hgweb/hgweb_mod.py:0:
447 mercurial/hgweb/hgweb_mod.py:0:
448 > self.maxshortchanges = int(self.config("web", "maxshortchanges", 60))
448 > self.maxshortchanges = int(self.config("web", "maxshortchanges", 60))
449 warning: line over 80 characters
449 warning: line over 80 characters
450 mercurial/keepalive.py:0:
450 mercurial/keepalive.py:0:
451 > except:
451 > except:
452 warning: naked except clause
452 warning: naked except clause
453 mercurial/keepalive.py:0:
453 mercurial/keepalive.py:0:
454 > except:
454 > except:
455 warning: naked except clause
455 warning: naked except clause
456 mercurial/localrepo.py:0:
456 mercurial/localrepo.py:0:
457 > # we return an integer indicating remote head count change
457 > # we return an integer indicating remote head count change
458 warning: line over 80 characters
458 warning: line over 80 characters
459 mercurial/localrepo.py:0:
459 mercurial/localrepo.py:0:
460 > raise util.Abort(_("empty or missing revlog for %s") % fname)
460 > raise util.Abort(_("empty or missing revlog for %s") % fname)
461 warning: line over 80 characters
461 warning: line over 80 characters
462 warning: line over 80 characters
462 warning: line over 80 characters
463 mercurial/localrepo.py:0:
463 mercurial/localrepo.py:0:
464 > if self._tagscache.tagtypes and name in self._tagscache.tagtypes:
464 > if self._tagscache.tagtypes and name in self._tagscache.tagtypes:
465 warning: line over 80 characters
465 warning: line over 80 characters
466 mercurial/localrepo.py:0:
466 mercurial/localrepo.py:0:
467 > self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2)
467 > self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2)
468 warning: line over 80 characters
468 warning: line over 80 characters
469 mercurial/localrepo.py:0:
469 mercurial/localrepo.py:0:
470 > # new requirements = old non-format requirements + new format-related
470 > # new requirements = old non-format requirements + new format-related
471 warning: line over 80 characters
471 warning: line over 80 characters
472 mercurial/localrepo.py:0:
472 mercurial/localrepo.py:0:
473 > except:
473 > except:
474 warning: naked except clause
474 warning: naked except clause
475 mercurial/localrepo.py:0:
475 mercurial/localrepo.py:0:
476 > """return status of files between two nodes or node and working directory
476 > """return status of files between two nodes or node and working directory
477 warning: line over 80 characters
477 warning: line over 80 characters
478 mercurial/localrepo.py:0:
478 mercurial/localrepo.py:0:
479 > '''Returns a tagscache object that contains various tags related caches.'''
479 > '''Returns a tagscache object that contains various tags related caches.'''
480 warning: line over 80 characters
480 warning: line over 80 characters
481 mercurial/manifest.py:0:
481 mercurial/manifest.py:0:
482 > return "".join(struct.pack(">lll", start, end, len(content)) + content
482 > return "".join(struct.pack(">lll", start, end, len(content)) + content
483 warning: line over 80 characters
483 warning: line over 80 characters
484 mercurial/merge.py:0:
484 mercurial/merge.py:0:
485 > subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite)
485 > subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite)
486 warning: line over 80 characters
486 warning: line over 80 characters
487 mercurial/patch.py:0:
487 mercurial/patch.py:0:
488 > modified, added, removed, copy, getfilectx, opts, losedata, prefix)
488 > modified, added, removed, copy, getfilectx, opts, losedata, prefix)
489 warning: line over 80 characters
489 warning: line over 80 characters
490 mercurial/patch.py:0:
490 mercurial/patch.py:0:
491 > diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb, self.a, self.b)
491 > diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb, self.a, self.b)
492 warning: line over 80 characters
492 warning: line over 80 characters
493 mercurial/patch.py:0:
493 mercurial/patch.py:0:
494 > output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n')
494 > output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n')
495 warning: line over 80 characters
495 warning: line over 80 characters
496 mercurial/patch.py:0:
496 mercurial/patch.py:0:
497 > except:
497 > except:
498 warning: naked except clause
498 warning: naked except clause
499 mercurial/pure/mpatch.py:0:
499 mercurial/pure/mpatch.py:0:
500 > frags.extend(reversed(new)) # what was left at the end
500 > frags.extend(reversed(new)) # what was left at the end
501 warning: line over 80 characters
501 warning: line over 80 characters
502 mercurial/repair.py:0:
502 mercurial/repair.py:0:
503 > except:
503 > except:
504 warning: naked except clause
504 warning: naked except clause
505 mercurial/repair.py:0:
505 mercurial/repair.py:0:
506 > except:
506 > except:
507 warning: naked except clause
507 warning: naked except clause
508 mercurial/revset.py:0:
508 mercurial/revset.py:0:
509 > elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword
509 > elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword
510 warning: line over 80 characters
510 warning: line over 80 characters
511 mercurial/revset.py:0:
511 mercurial/revset.py:0:
512 > Changesets that are the Nth ancestor (first parents only) of a changeset in set.
512 > Changesets that are the Nth ancestor (first parents only) of a changeset in set.
513 warning: line over 80 characters
513 warning: line over 80 characters
514 mercurial/scmutil.py:0:
514 mercurial/scmutil.py:0:
515 > raise util.Abort(_("path '%s' is inside nested repo %r") %
515 > raise util.Abort(_("path '%s' is inside nested repo %r") %
516 warning: line over 80 characters
516 warning: line over 80 characters
517 mercurial/scmutil.py:0:
517 mercurial/scmutil.py:0:
518 > "requires features '%s' (upgrade Mercurial)") % "', '".join(missings))
518 > "requires features '%s' (upgrade Mercurial)") % "', '".join(missings))
519 warning: line over 80 characters
519 warning: line over 80 characters
520 mercurial/scmutil.py:0:
520 mercurial/scmutil.py:0:
521 > elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target)
521 > elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target)
522 warning: line over 80 characters
522 warning: line over 80 characters
523 mercurial/setdiscovery.py:0:
523 mercurial/setdiscovery.py:0:
524 > # treat remote heads (and maybe own heads) as a first implicit sample response
524 > # treat remote heads (and maybe own heads) as a first implicit sample response
525 warning: line over 80 characters
525 warning: line over 80 characters
526 mercurial/setdiscovery.py:0:
526 mercurial/setdiscovery.py:0:
527 > undecided = dag.nodeset() # own nodes where I don't know if remote knows them
527 > undecided = dag.nodeset() # own nodes where I don't know if remote knows them
528 warning: line over 80 characters
528 warning: line over 80 characters
529 mercurial/similar.py:0:
529 mercurial/similar.py:0:
530 > repo.ui.progress(_('searching for similar files'), i, total=len(removed))
530 > repo.ui.progress(_('searching for similar files'), i, total=len(removed))
531 warning: line over 80 characters
531 warning: line over 80 characters
532 mercurial/simplemerge.py:0:
532 mercurial/simplemerge.py:0:
533 > for zmatch, zend, amatch, aend, bmatch, bend in self.find_sync_regions():
533 > for zmatch, zend, amatch, aend, bmatch, bend in self.find_sync_regions():
534 warning: line over 80 characters
534 warning: line over 80 characters
535 mercurial/sshrepo.py:0:
535 mercurial/sshrepo.py:0:
536 > self._abort(error.RepoError(_("no suitable response from remote hg")))
536 > self._abort(error.RepoError(_("no suitable response from remote hg")))
537 warning: line over 80 characters
537 warning: line over 80 characters
538 mercurial/sshrepo.py:0:
538 mercurial/sshrepo.py:0:
539 > except:
539 > except:
540 warning: naked except clause
540 warning: naked except clause
541 mercurial/subrepo.py:0:
541 mercurial/subrepo.py:0:
542 > other, self._repo = hg.clone(self._repo._subparent.ui, {}, other,
542 > other, self._repo = hg.clone(self._repo._subparent.ui, {}, other,
543 warning: line over 80 characters
543 warning: line over 80 characters
544 mercurial/subrepo.py:0:
544 mercurial/subrepo.py:0:
545 > msg = (_(' subrepository sources for %s differ (in checked out version)\n'
545 > msg = (_(' subrepository sources for %s differ (in checked out version)\n'
546 warning: line over 80 characters
546 warning: line over 80 characters
547 mercurial/transaction.py:0:
547 mercurial/transaction.py:0:
548 > except:
548 > except:
549 warning: naked except clause
549 warning: naked except clause
550 mercurial/ui.py:0:
550 mercurial/ui.py:0:
551 > traceback.print_exception(exc[0], exc[1], exc[2], file=self.ferr)
551 > traceback.print_exception(exc[0], exc[1], exc[2], file=self.ferr)
552 warning: line over 80 characters
552 warning: line over 80 characters
553 mercurial/url.py:0:
553 mercurial/url.py:0:
554 > conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs)
554 > conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs)
555 warning: line over 80 characters
555 warning: line over 80 characters
556 mercurial/util.py:0:
556 mercurial/util.py:0:
557 > except:
557 > except:
558 warning: naked except clause
558 warning: naked except clause
559 mercurial/util.py:0:
559 mercurial/util.py:0:
560 > except:
560 > except:
561 warning: naked except clause
561 warning: naked except clause
562 mercurial/verify.py:0:
562 mercurial/verify.py:0:
563 > except:
563 > except:
564 warning: naked except clause
564 warning: naked except clause
565 mercurial/verify.py:0:
565 mercurial/verify.py:0:
566 > except:
566 > except:
567 warning: naked except clause
567 warning: naked except clause
568 mercurial/wireproto.py:0:
568 mercurial/wireproto.py:0:
569 > # Assuming the future to be filled with the result from the batched request
569 > # Assuming the future to be filled with the result from the batched request
570 warning: line over 80 characters
570 warning: line over 80 characters
571 mercurial/wireproto.py:0:
571 mercurial/wireproto.py:0:
572 > '''remote must support _submitbatch(encbatch) and _submitone(op, encargs)'''
572 > '''remote must support _submitbatch(encbatch) and _submitone(op, encargs)'''
573 warning: line over 80 characters
573 warning: line over 80 characters
574 mercurial/wireproto.py:0:
574 mercurial/wireproto.py:0:
575 > All methods invoked on instances of this class are simply queued and return a
575 > All methods invoked on instances of this class are simply queued and return a
576 warning: line over 80 characters
576 warning: line over 80 characters
577 mercurial/wireproto.py:0:
577 mercurial/wireproto.py:0:
578 > The decorator returns a function which wraps this coroutine as a plain method,
578 > The decorator returns a function which wraps this coroutine as a plain method,
579 warning: line over 80 characters
579 warning: line over 80 characters
580 setup.py:0:
580 setup.py:0:
581 > raise SystemExit("Python headers are required to build Mercurial")
581 > raise SystemExit("Python headers are required to build Mercurial")
582 warning: line over 80 characters
582 warning: line over 80 characters
583 setup.py:0:
583 setup.py:0:
584 > except:
584 > except:
585 warning: naked except clause
585 warning: naked except clause
586 setup.py:0:
586 setup.py:0:
587 > # build_py), it will not find osutil & friends, thinking that those modules are
587 > # build_py), it will not find osutil & friends, thinking that those modules are
588 warning: line over 80 characters
588 warning: line over 80 characters
589 setup.py:0:
589 setup.py:0:
590 > except:
590 > except:
591 warning: naked except clause
591 warning: naked except clause
592 warning: naked except clause
592 warning: naked except clause
593 setup.py:0:
593 setup.py:0:
594 > isironpython = platform.python_implementation().lower().find("ironpython") != -1
594 > isironpython = platform.python_implementation().lower().find("ironpython") != -1
595 warning: line over 80 characters
595 warning: line over 80 characters
596 setup.py:0:
596 setup.py:0:
597 > except:
597 > except:
598 warning: naked except clause
598 warning: naked except clause
599 warning: naked except clause
599 warning: naked except clause
600 warning: naked except clause
600 warning: naked except clause
601 tests/autodiff.py:0:
601 tests/autodiff.py:0:
602 > ui.write('data lost for: %s\n' % fn)
602 > ui.write('data lost for: %s\n' % fn)
603 warning: unwrapped ui message
603 warning: unwrapped ui message
604 tests/run-tests.py:0:
604 tests/run-tests.py:0:
605 > except:
605 > except:
606 warning: naked except clause
606 warning: naked except clause
607 tests/test-commandserver.py:0:
607 tests/test-commandserver.py:0:
608 > 'hooks.pre-identify=python:test-commandserver.hook', 'id'],
608 > 'hooks.pre-identify=python:test-commandserver.hook', 'id'],
609 warning: line over 80 characters
609 warning: line over 80 characters
610 tests/test-commandserver.py:0:
610 tests/test-commandserver.py:0:
611 > # the cached repo local hgrc contains ui.foo=bar, so showconfig should show it
611 > # the cached repo local hgrc contains ui.foo=bar, so showconfig should show it
612 warning: line over 80 characters
612 warning: line over 80 characters
613 tests/test-commandserver.py:0:
613 tests/test-commandserver.py:0:
614 > print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data))
614 > print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data))
615 warning: line over 80 characters
615 warning: line over 80 characters
616 tests/test-convert-mtn.t:0:
617 > > function get_passphrase(keypair_id)
618 don't use 'function', use old style
616 tests/test-filecache.py:0:
619 tests/test-filecache.py:0:
617 > except:
620 > except:
618 warning: naked except clause
621 warning: naked except clause
619 tests/test-filecache.py:0:
622 tests/test-filecache.py:0:
620 > if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'], 'cacheable']):
623 > if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'], 'cacheable']):
621 warning: line over 80 characters
624 warning: line over 80 characters
625 tests/test-import-git.t:0:
626 > > Mc\${NkU|\`?^000jF3jhEB
627 ^ must be quoted
628 tests/test-import.t:0:
629 > > diff -Naur proj-orig/foo proj-new/foo
630 don't use 'diff -N'
631 don't use 'diff -N'
632 tests/test-schemes.t:0:
633 > > z = file:\$PWD/
634 don't use $PWD, use `pwd`
622 tests/test-ui-color.py:0:
635 tests/test-ui-color.py:0:
623 > testui.warn('warning\n')
636 > testui.warn('warning\n')
624 warning: unwrapped ui message
637 warning: unwrapped ui message
625 tests/test-ui-color.py:0:
638 tests/test-ui-color.py:0:
626 > testui.write('buffered\n')
639 > testui.write('buffered\n')
627 warning: unwrapped ui message
640 warning: unwrapped ui message
628 tests/test-walkrepo.py:0:
641 tests/test-walkrepo.py:0:
629 > print "Found %d repositories when I should have found 2" % (len(reposet),)
642 > print "Found %d repositories when I should have found 2" % (len(reposet),)
630 warning: line over 80 characters
643 warning: line over 80 characters
631 tests/test-walkrepo.py:0:
644 tests/test-walkrepo.py:0:
632 > print "Found %d repositories when I should have found 3" % (len(reposet),)
645 > print "Found %d repositories when I should have found 3" % (len(reposet),)
633 warning: line over 80 characters
646 warning: line over 80 characters
General Comments 0
You need to be logged in to leave comments. Login now