import-checker: treat "from mercurial import XXXX" style correctly
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 17 Oct 2014 02:07:05 +0900
changeset 22974 6bd43614d387
parent 22973 bcff9ecdaae0
child 22975 461342e1c8aa
import-checker: treat "from mercurial import XXXX" style correctly Before this patch, "import-checker.py" assumes that the name of Mercurial module recognized by "imported_modules" doesn't have package part: for example, "util". This is reason why "import-checker.py" always builds fully qualified module name up relatively, if the given module doesn't belong to standard Python library. But in fact, modules imported in "from mercurial import XXXX" style already have fully qualified name: for example, "mercurial.util" module imported by "mercurial.parsers" is treated as "mercurial.mercurial.util" because of building module name up relatively. This prevents "import-checker.py" from correctly checking about cyclic dependency in them. This patch avoids building module name up relatively, also if module name starts with "mercurial.", to treat modules imported in "from mercurial import XXXX" style correctly.
contrib/import-checker.py
--- a/contrib/import-checker.py	Fri Oct 17 02:07:04 2014 +0900
+++ b/contrib/import-checker.py	Fri Oct 17 02:07:05 2014 +0900
@@ -169,7 +169,7 @@
         ignore = []
     path = path + [mod]
     for i in sorted(imports.get(mod, [])):
-        if i not in stdlib_modules:
+        if i not in stdlib_modules and not i.startswith('mercurial.'):
             i = mod.rsplit('.', 1)[0] + '.' + i
         if i in path:
             firstspot = path.index(i)