[PATCH 3 of 4 V2] import-checker: remove useless module name supposition in checkmod
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri May 15 14:13:47 UTC 2015
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1431699038 -32400
# Fri May 15 23:10:38 2015 +0900
# Node ID 0403363ab33ce62c84ab1fc004da081357516362
# Parent ab820b3793cc9a2680cc90f11fd760750c276adb
import-checker: remove useless module name supposition in checkmod
Previous patch ensures that all module names stored in "imports" are
absolute one, and it makes module name supposition in "checkmod" useless.
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -279,8 +279,6 @@ def checkmod(mod, imports):
while visit:
path = visit.pop(0)
for i in sorted(imports.get(path[-1], [])):
- if i not in stdlib_modules and not i.startswith('mercurial.'):
- i = mod.rsplit('.', 1)[0] + '.' + i
if len(path) < shortest.get(i, 1000):
shortest[i] = len(path)
if i in path:
@@ -302,10 +300,12 @@ def rotatecycle(cycle):
def find_cycles(imports):
"""Find cycles in an already-loaded import graph.
- >>> imports = {'top.foo': ['bar', 'os.path', 'qux'],
- ... 'top.bar': ['baz', 'sys'],
- ... 'top.baz': ['foo'],
- ... 'top.qux': ['foo']}
+ All module names contained in `imports` should be absolute one.
+
+ >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'],
+ ... 'top.bar': ['top.baz', 'sys'],
+ ... 'top.baz': ['top.foo'],
+ ... 'top.qux': ['top.foo']}
>>> print '\\n'.join(sorted(find_cycles(imports)))
top.bar -> top.baz -> top.foo -> top.bar
top.foo -> top.qux -> top.foo
More information about the Mercurial-devel
mailing list