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.
--- 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))