Show More
@@ -30,10 +30,8 b' parser.add_option("--test-features", act' | |||||
30 | help="test available features") |
|
30 | help="test available features") | |
31 | parser.add_option("--list-features", action="store_true", |
|
31 | parser.add_option("--list-features", action="store_true", | |
32 | help="list available features") |
|
32 | help="list available features") | |
33 | parser.add_option("-q", "--quiet", action="store_true", |
|
|||
34 | help="check features silently") |
|
|||
35 |
|
33 | |||
36 |
def _loadaddon( |
|
34 | def _loadaddon(): | |
37 | if 'TESTDIR' in os.environ: |
|
35 | if 'TESTDIR' in os.environ: | |
38 | # loading from '.' isn't needed, because `hghave` should be |
|
36 | # loading from '.' isn't needed, because `hghave` should be | |
39 | # running at TESTTMP in this case |
|
37 | # running at TESTTMP in this case | |
@@ -48,15 +46,14 b' def _loadaddon(quiet):' | |||||
48 | try: |
|
46 | try: | |
49 | import hghaveaddon |
|
47 | import hghaveaddon | |
50 | except BaseException, inst: |
|
48 | except BaseException, inst: | |
51 | if not quiet: |
|
49 | sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n' | |
52 | sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n' |
|
50 | % (path, inst)) | |
53 | % (path, inst)) |
|
|||
54 | sys.exit(2) |
|
51 | sys.exit(2) | |
55 | sys.path.pop(0) |
|
52 | sys.path.pop(0) | |
56 |
|
53 | |||
57 | if __name__ == '__main__': |
|
54 | if __name__ == '__main__': | |
58 | options, args = parser.parse_args() |
|
55 | options, args = parser.parse_args() | |
59 |
_loadaddon( |
|
56 | _loadaddon() | |
60 | if options.list_features: |
|
57 | if options.list_features: | |
61 | list_features() |
|
58 | list_features() | |
62 | sys.exit(0) |
|
59 | sys.exit(0) | |
@@ -64,4 +61,4 b" if __name__ == '__main__':" | |||||
64 | if options.test_features: |
|
61 | if options.test_features: | |
65 | sys.exit(test_features()) |
|
62 | sys.exit(test_features()) | |
66 |
|
63 | |||
67 |
hghave.require(args |
|
64 | hghave.require(args) |
@@ -47,17 +47,16 b' def checkfeatures(features):' | |||||
47 |
|
47 | |||
48 | return result |
|
48 | return result | |
49 |
|
49 | |||
50 |
def require(features |
|
50 | def require(features): | |
51 | """Require that features are available, exiting if not.""" |
|
51 | """Require that features are available, exiting if not.""" | |
52 | result = checkfeatures(features) |
|
52 | result = checkfeatures(features) | |
53 |
|
53 | |||
54 | if not quiet: |
|
54 | for missing in result['missing']: | |
55 | for missing in result['missing']: |
|
55 | sys.stderr.write('skipped: unknown feature: %s\n' % missing) | |
56 | sys.stderr.write('skipped: unknown feature: %s\n' % missing) |
|
56 | for msg in result['skipped']: | |
57 | for msg in result['skipped']: |
|
57 | sys.stderr.write('skipped: %s\n' % msg) | |
58 | sys.stderr.write('skipped: %s\n' % msg) |
|
58 | for msg in result['error']: | |
59 | for msg in result['error']: |
|
59 | sys.stderr.write('%s\n' % msg) | |
60 | sys.stderr.write('%s\n' % msg) |
|
|||
61 |
|
60 | |||
62 | if result['missing']: |
|
61 | if result['missing']: | |
63 | sys.exit(2) |
|
62 | sys.exit(2) |
General Comments 0
You need to be logged in to leave comments.
Login now