import-checker: loop to get list of locally defined modules at first
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Thu, 14 May 2015 01:49:10 +0900
changeset 25064 3bbbadf69d0a
parent 25063 723e364488f4
child 25065 8cf7f0c4cb14
import-checker: loop to get list of locally defined modules at first This is a preparation for subsequent patches, which expect that all locally defined (= mercurial specific) modules are already known before examinations. Looping twice for specified modules is a little redundant, but reasonable cost for improvement in subsequent patches.
contrib/import-checker.py
--- a/contrib/import-checker.py	Thu May 14 01:49:10 2015 +0900
+++ b/contrib/import-checker.py	Thu May 14 01:49:10 2015 +0900
@@ -221,11 +221,14 @@
     if argv[1] == '-':
         argv = argv[:1]
         argv.extend(l.rstrip() for l in sys.stdin.readlines())
+    localmods = {}
     used_imports = {}
     any_errors = False
     for source_path in argv[1:]:
+        modname = dotted_name_of_path(source_path, trimpure=True)
+        localmods[modname] = source_path
+    for modname, source_path in sorted(localmods.iteritems()):
         f = open(source_path)
-        modname = dotted_name_of_path(source_path, trimpure=True)
         src = f.read()
         used_imports[modname] = sorted(
             imported_modules(src, ignore_nested=True))