Mercurial > hg
view tests/hghave @ 25795:69145daacdfa
cmdutil: allow callers of cmdutil.dorecord to omit suggestion
Interactive committing under non-interactive mode shows command
suggestion, but sometimes it is meaningless.
command suggestion usability
------------ ---------- -----------
record commit
commit -i commit meaningless
qrecord qnew
qnew -i qnew meaningless
qrefersh -i qrefresh meaningless
shelve -i commit incorrect
------------ ---------- -----------
This patch allows callers of 'cmdutil.dorecord()' to omit meaningless
suggestion by passing None or so for 'cmdsuggest' argument of it.
This is a preparation for subsequent patches, which fix each
suggestion issues above.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 15 Jul 2015 03:43:16 +0900 |
parents | b94df10cc3b5 |
children | 8107c308ff22 |
line wrap: on
line source
#!/usr/bin/env python """Test the running system for features availability. Exit with zero if all features are there, non-zero otherwise. If a feature name is prefixed with "no-", the absence of feature is tested. """ import optparse import os, sys import hghave checks = hghave.checks def list_features(): for name, feature in sorted(checks.iteritems()): desc = feature[1] print name + ':', desc def test_features(): failed = 0 for name, feature in checks.iteritems(): check, _ = feature try: check() except Exception, e: print "feature %s failed: %s" % (name, e) failed += 1 return failed parser = optparse.OptionParser("%prog [options] [features]") parser.add_option("--test-features", action="store_true", help="test available features") parser.add_option("--list-features", action="store_true", help="list available features") parser.add_option("-q", "--quiet", action="store_true", help="check features silently") def _loadaddon(quiet): if 'TESTDIR' in os.environ: # loading from '.' isn't needed, because `hghave` should be # running at TESTTMP in this case path = os.environ['TESTDIR'] else: path = '.' if not os.path.exists(os.path.join(path, 'hghaveaddon.py')): return sys.path.insert(0, path) try: import hghaveaddon except BaseException, inst: if not quiet: sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n' % (path, inst)) sys.exit(2) sys.path.pop(0) if __name__ == '__main__': options, args = parser.parse_args() _loadaddon(options.quiet) if options.list_features: list_features() sys.exit(0) if options.test_features: sys.exit(test_features()) quiet = options.quiet failures = 0 def error(msg): global failures if not quiet: sys.stderr.write(msg + '\n') failures += 1 for feature in args: negate = feature.startswith('no-') if negate: feature = feature[3:] if feature not in checks: error('skipped: unknown feature: ' + feature) sys.exit(2) check, desc = checks[feature] try: available = check() except Exception, e: error('hghave check failed: ' + feature) continue if not negate and not available: error('skipped: missing feature: ' + desc) elif negate and available: error('skipped: system supports %s' % desc) if failures != 0: sys.exit(1)