[PATCH 2 of 6] import-checker: loop to get list of locally defined modules at first
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed May 13 11:53:55 CDT 2015
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1431535750 -32400
# Thu May 14 01:49:10 2015 +0900
# Node ID d96e5eeff38853397e32a354a94052c4687535c0
# Parent 35d7390522fd643548bdd9a1d1ef059d94f80698
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.
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -221,11 +221,14 @@ def main(argv):
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))
More information about the Mercurial-devel
mailing list