Show More
@@ -368,15 +368,15 b' inrevlogpats = [' | |||||
368 | ] |
|
368 | ] | |
369 |
|
369 | |||
370 | checks = [ |
|
370 | checks = [ | |
371 | ('python', r'.*\.(py|cgi)$', pyfilters, pypats), |
|
371 | ('python', r'.*\.(py|cgi)$', r'^#!.*python', pyfilters, pypats), | |
372 | ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats), |
|
372 | ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats), | |
373 | ('c', r'.*\.[ch]$', cfilters, cpats), |
|
373 | ('c', r'.*\.[ch]$', '', cfilters, cpats), | |
374 | ('unified test', r'.*\.t$', utestfilters, utestpats), |
|
374 | ('unified test', r'.*\.t$', '', utestfilters, utestpats), | |
375 |
('layering violation repo in revlog', r'mercurial/revlog\.py', |
|
375 | ('layering violation repo in revlog', r'mercurial/revlog\.py', '', | |
376 | inrevlogpats), |
|
376 | pyfilters, inrevlogpats), | |
377 | ('layering violation ui in util', r'mercurial/util\.py', pyfilters, |
|
377 | ('layering violation ui in util', r'mercurial/util\.py', '', pyfilters, | |
378 | inutilpats), |
|
378 | inutilpats), | |
379 | ('txt', r'.*\.txt$', txtfilters, txtpats), |
|
379 | ('txt', r'.*\.txt$', '', txtfilters, txtpats), | |
380 | ] |
|
380 | ] | |
381 |
|
381 | |||
382 | def _preparepats(): |
|
382 | def _preparepats(): | |
@@ -392,7 +392,7 b' def _preparepats():' | |||||
392 | p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p) |
|
392 | p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p) | |
393 |
|
393 | |||
394 | pats[i] = (re.compile(p, re.MULTILINE),) + pseq[1:] |
|
394 | pats[i] = (re.compile(p, re.MULTILINE),) + pseq[1:] | |
395 |
filters = c[ |
|
395 | filters = c[3] | |
396 | for i, flt in enumerate(filters): |
|
396 | for i, flt in enumerate(filters): | |
397 | filters[i] = re.compile(flt[0]), flt[1] |
|
397 | filters[i] = re.compile(flt[0]), flt[1] | |
398 | _preparepats() |
|
398 | _preparepats() | |
@@ -446,22 +446,24 b' def checkfile(f, logfunc=_defaultlogger.' | |||||
446 | """ |
|
446 | """ | |
447 | blamecache = None |
|
447 | blamecache = None | |
448 | result = True |
|
448 | result = True | |
449 | for name, match, filters, pats in checks: |
|
449 | ||
|
450 | try: | |||
|
451 | fp = open(f) | |||
|
452 | except IOError, e: | |||
|
453 | print "Skipping %s, %s" % (f, str(e).split(':', 1)[0]) | |||
|
454 | return result | |||
|
455 | pre = post = fp.read() | |||
|
456 | fp.close() | |||
|
457 | ||||
|
458 | for name, match, magic, filters, pats in checks: | |||
450 | if debug: |
|
459 | if debug: | |
451 | print name, f |
|
460 | print name, f | |
452 | fc = 0 |
|
461 | fc = 0 | |
453 | if not re.match(match, f): |
|
462 | if not (re.match(match, f) or (magic and re.search(magic, f))): | |
454 | if debug: |
|
463 | if debug: | |
455 | print "Skipping %s for %s it doesn't match %s" % ( |
|
464 | print "Skipping %s for %s it doesn't match %s" % ( | |
456 | name, match, f) |
|
465 | name, match, f) | |
457 | continue |
|
466 | continue | |
458 | try: |
|
|||
459 | fp = open(f) |
|
|||
460 | except IOError, e: |
|
|||
461 | print "Skipping %s, %s" % (f, str(e).split(':', 1)[0]) |
|
|||
462 | continue |
|
|||
463 | pre = post = fp.read() |
|
|||
464 | fp.close() |
|
|||
465 | if "no-" "check-code" in pre: |
|
467 | if "no-" "check-code" in pre: | |
466 | print "Skipping %s it has no-" "check-code" % f |
|
468 | print "Skipping %s it has no-" "check-code" % f | |
467 | return "Skip" # skip checking this file |
|
469 | return "Skip" # skip checking this file |
General Comments 0
You need to be logged in to leave comments.
Login now