[PATCH 01 of 22] check-code: allow "from mercurial.(pure|cext) import x as y"
Jun Wu
quark at fb.com
Sun Jun 4 23:59:13 UTC 2017
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1496444920 25200
# Fri Jun 02 16:08:40 2017 -0700
# Node ID 5c3500de0a229d8aa08058bccec531d8a85b90d9
# Parent 783394c0c97807e83daad9da561179bd0719e159
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r 5c3500de0a22
check-code: allow "from mercurial.(pure|cext) import x as y"
We want to forbid things like "from mercurial.cext import parsers". But
sometimes it's useful to import a package directly. When that happens, the
code probably wants an alternative name for the module using "as ...".
This pattern will be used by the next patch.
diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -342,5 +342,5 @@ pypats = [
(r'^import BaseHTTPServer', "use util.httpserver instead"),
(r'^(from|import) mercurial\.(cext|pure|cffi)',
- "use mercurial.policy.importmod instead"),
+ "use mercurial.policy.importmod instead", r' as \S*$'),
(r'\.next\(\)', "don't use .next(), use next(...)"),
(r'([a-z]*).revision\(\1\.node\(',
More information about the Mercurial-devel
mailing list