[PATCH v2] check-code: skip unhandled files

timeless timeless at fmr.im
Wed May 11 17:32:01 UTC 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1462930640 0
#      Wed May 11 01:37:20 2016 +0000
# Node ID 12720ea9628e81605c45c4c7a11e9b8a0902eccc
# Parent  c641b8dfb98c2ade6995ba3aa341fe4d7b154827
# Available At bb://timeless/mercurial-crew
#              hg pull bb://timeless/mercurial-crew -r 12720ea9628e
check-code: skip unhandled files

check-code is organized into a list of file patterns for which there
are a list of string patterns in which to look for strings (and then
complain if matches are found).

It doesn't make sense to open files for which there are no matching
file patterns. So, we compile the matching file patterns and then
skip anything that doesn't match them.

diff -r c641b8dfb98c -r 12720ea9628e contrib/check-code.py
--- a/contrib/check-code.py	Wed May 11 01:46:11 2016 +0000
+++ b/contrib/check-code.py	Wed May 11 01:37:20 2016 +0000
@@ -426,6 +426,8 @@
     ('web template', r'mercurial/templates/.*\.tmpl', '',
      webtemplatefilters, webtemplatepats),
 ]
+filechecks = r'|'.join([c[1] for c in checks])
+filecheckre = re.compile(filechecks)
 
 def _preparepats():
     for c in checks:
@@ -615,6 +617,10 @@
 
     ret = 0
     for f in check:
+        if not filecheckre.search(f):
+            if options.debug:
+                print("Ignoring %s" % f)
+            continue
         if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
                          blame=options.blame, debug=options.debug,
                          lineno=options.lineno):


More information about the Mercurial-devel mailing list