Patchwork [2,of,5] check-code: skip unhandled files

login
register
mail settings
Submitter timeless
Date May 11, 2016, 4:12 a.m.
Message ID <6d203832806957d66c71.1462939967@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/14988/
State Accepted
Headers show

Comments

timeless - May 11, 2016, 4:12 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1462930640 0
#      Wed May 11 01:37:20 2016 +0000
# Node ID 6d203832806957d66c7144fa415f9cf0f3724c9c
# Parent  0ae3c041551b65d04ce0cccecf5343cf86afc2d5
# EXP-Topic runtests
# Available At bb://timeless/mercurial-crew
#              hg pull bb://timeless/mercurial-crew -r 6d2038328069
check-code: skip unhandled files
Pierre-Yves David - May 11, 2016, 5:11 p.m.
On 05/11/2016 06:12 AM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1462930640 0
> #      Wed May 11 01:37:20 2016 +0000
> # Node ID 6d203832806957d66c7144fa415f9cf0f3724c9c
> # Parent  0ae3c041551b65d04ce0cccecf5343cf86afc2d5
> # EXP-Topic runtests
> # Available At bb://timeless/mercurial-crew
> #              hg pull bb://timeless/mercurial-crew -r 6d2038328069
> check-code: skip unhandled files

I'm not sure what this changeset is about. Can you resend with and 
updated description?

I've taken all the other patches of the series. Thanks



>
> diff -r 0ae3c041551b -r 6d2038328069 contrib/check-code.py
> --- a/contrib/check-code.py	Wed May 11 01:56:08 2016 +0000
> +++ b/contrib/check-code.py	Wed May 11 01:37:20 2016 +0000
> @@ -417,6 +417,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:
> @@ -603,6 +605,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):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
timeless - May 11, 2016, 5:16 p.m.
> I'm not sure what this changeset is about.

Basically the current code scans every file in the repository, opening
it, reading it (*), and then trying to decide if there are any file
patterns / source patterns that violate rules.

But, we know which file patterns exist, so there's really no reason to
try to open the files if there aren't any patterns to read.

* Without some of the later patches, py3 would crash trying to "read"
pyc/png/random binary files as unicode/ascii/whatever its defalut
encoding was.

> Can you resend with and updated description?

I will.

Patch

diff -r 0ae3c041551b -r 6d2038328069 contrib/check-code.py
--- a/contrib/check-code.py	Wed May 11 01:56:08 2016 +0000
+++ b/contrib/check-code.py	Wed May 11 01:37:20 2016 +0000
@@ -417,6 +417,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:
@@ -603,6 +605,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):