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