diff contrib/import-checker.py @ 25063:723e364488f4

import-checker: add xargs like mode Before this patch, "import-check.py" is invoked via "xargs" in "test-module-imports.t", but it doesn't ensure that "import-checker.py" is certainly invoked with all mercurial specific files at once. "xargs" may invoke specified command multiple times with part of arguments given from stdin: according to "xargs(1)" man page, this dividing arguments is system-dependent. This patch adds "xargs" like mode to "import-checker.py". This can ensure that "import-checker.py" is certainly invoked with all mercurial specific files at once in "test-module-imports.t". This is assumed by subsequent patches.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 14 May 2015 01:49:10 +0900
parents fbdbff1b486a
children 3bbbadf69d0a
line wrap: on
line diff
--- a/contrib/import-checker.py	Wed May 13 20:36:56 2015 +0200
+++ b/contrib/import-checker.py	Thu May 14 01:49:10 2015 +0900
@@ -215,9 +215,12 @@
     return len(c), c
 
 def main(argv):
-    if len(argv) < 2:
-        print 'Usage: %s file [file] [file] ...'
+    if len(argv) < 2 or (argv[1] == '-' and len(argv) > 2):
+        print 'Usage: %s {-|file [file] [file] ...}'
         return 1
+    if argv[1] == '-':
+        argv = argv[:1]
+        argv.extend(l.rstrip() for l in sys.stdin.readlines())
     used_imports = {}
     any_errors = False
     for source_path in argv[1:]: