check-code: suggest policy.importmod
authorJun Wu <quark@fb.com>
Wed, 31 May 2017 11:41:54 -0700
changeset 32604 071423d0a584
parent 32603 5d44d7d4076e
child 32605 e6ff007e107e
check-code: suggest policy.importmod This forbids patterns like `from mercurial.cext import parsers` which breaks pure.
contrib/check-code.py
--- a/contrib/check-code.py	Fri May 26 03:41:10 2017 +0200
+++ b/contrib/check-code.py	Wed May 31 11:41:54 2017 -0700
@@ -340,6 +340,8 @@
     (r'^import pickle', "don't use pickle, use util.pickle"),
     (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\(',
      "don't convert rev to node before passing to revision(nodeorrev)"),