changeset 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 b7a8e9fa605f
children 3bbbadf69d0a
files contrib/import-checker.py tests/test-module-imports.t
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
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:]:
--- a/tests/test-module-imports.t	Wed May 13 20:36:56 2015 +0200
+++ b/tests/test-module-imports.t	Thu May 14 01:49:10 2015 +0900
@@ -20,7 +20,7 @@
 hidden by deduplication algorithm in the cycle detector, so fixing
 these may expose other cycles.
 
-  $ hg locate 'mercurial/**.py' | sed 's-\\-/-g' | xargs python "$import_checker"
+  $ hg locate 'mercurial/**.py' | sed 's-\\-/-g' | python "$import_checker" -
   mercurial/dispatch.py mixed imports
      stdlib:    commands
      relative:  error, extensions, fancyopts, hg, hook, util