From patchwork Fri May 15 14:13:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 4, V2] import-checker: remove useless module name supposition in checkmod From: Katsunori FUJIWARA X-Patchwork-Id: 9096 Message-Id: <0403363ab33ce62c84ab.1431699227@juju> To: mercurial-devel@selenic.com Date: Fri, 15 May 2015 23:13:47 +0900 # HG changeset patch # User FUJIWARA Katsunori # 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