Patchwork check-code: suggest policy.importmod

login
register
mail settings
Submitter Jun Wu
Date May 31, 2017, 6:44 p.m.
Message ID <7827171727234eac61bc.1496256269@x1c>
Download mbox | patch
Permalink /patch/21092/
State Accepted
Headers show

Comments

Jun Wu - May 31, 2017, 6:44 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1496256114 25200
#      Wed May 31 11:41:54 2017 -0700
# Node ID 7827171727234eac61bc993b8f85ef5eee45c945
# Parent  5313d98089f569efffaca25de60e73be04156713
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 782717172723
check-code: suggest policy.importmod

This forbids patterns like `from mercurial.cext import parsers` which breaks
pure.
Augie Fackler - May 31, 2017, 7:27 p.m.
> On May 31, 2017, at 14:44, Jun Wu <quark@fb.com> wrote:
> 
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1496256114 25200
> #      Wed May 31 11:41:54 2017 -0700
> # Node ID 7827171727234eac61bc993b8f85ef5eee45c945
> # Parent  5313d98089f569efffaca25de60e73be04156713
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 782717172723
> check-code: suggest policy.importmod

Good call. Queued, thanks.


> This forbids patterns like `from mercurial.cext import parsers` which breaks
> pure.
> 
> diff --git a/contrib/check-code.py b/contrib/check-code.py
> --- a/contrib/check-code.py
> +++ b/contrib/check-code.py
> @@ -341,4 +341,6 @@ pypats = [
>     (r'^import httplib', "don't use httplib, use util.httplib"),
>     (r'^import BaseHTTPServer', "use util.httpserver instead"),
> +    (r'^(from|import) mercurial\.(cext|pure|cffi)',
> +     "use mercurial.policy.importmod instead"),
>     (r'\.next\(\)', "don't use .next(), use next(...)"),
>     (r'([a-z]*).revision\(\1\.node\(',
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -341,4 +341,6 @@  pypats = [
     (r'^import httplib', "don't use httplib, use util.httplib"),
     (r'^import BaseHTTPServer', "use util.httpserver instead"),
+    (r'^(from|import) mercurial\.(cext|pure|cffi)',
+     "use mercurial.policy.importmod instead"),
     (r'\.next\(\)', "don't use .next(), use next(...)"),
     (r'([a-z]*).revision\(\1\.node\(',