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