[PATCH 1 of 6] import-checker: add xargs like mode
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed May 13 16:53:54 UTC 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 35d7390522fd643548bdd9a1d1ef059d94f80698
# Parent 10bbdcd8916436f65aa0217b672528acaa0b3db8
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.
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -215,9 +215,12 @@ def _cycle_sortkey(c):
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:]:
diff --git a/tests/test-module-imports.t b/tests/test-module-imports.t
--- a/tests/test-module-imports.t
+++ b/tests/test-module-imports.t
@@ -20,7 +20,7 @@ here that we should still endeavor to fi
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
More information about the Mercurial-devel
mailing list