##// END OF EJS Templates
revsetbenchmark: use optparse to retrieve argument...
Pierre-Yves David -
r21287:2d93b743 default
parent child Browse files
Show More
@@ -15,6 +15,10 b''
15
15
16 import sys
16 import sys
17 from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE
17 from subprocess import check_call, Popen, CalledProcessError, STDOUT, PIPE
18 # cannot use argparse, python 2.7 only
19 from optparse import OptionParser
20
21
18
22
19 def check_output(*args, **kwargs):
23 def check_output(*args, **kwargs):
20 kwargs.setdefault('stderr', PIPE)
24 kwargs.setdefault('stderr', PIPE)
@@ -65,16 +69,22 b' def getrevs(spec):'
65 return [r for r in out.split() if r]
69 return [r for r in out.split() if r]
66
70
67
71
72 parser = OptionParser(usage="usage: %prog [options] <revs>")
73 parser.add_option("-f", "--file",
74 help="read revset from FILE", metavar="FILE")
75
76 (options, args) = parser.parse_args()
68
77
69 if len(sys.argv) < 2:
78 if len(sys.argv) < 2:
70 print >> sys.stderr, 'usage: %s <revs> [file]' % sys.argv[0]
79 parser.print_help()
71 sys.exit(255)
80 sys.exit(255)
72
81
73 target_rev = sys.argv[1]
82
83 target_rev = args[0]
74
84
75 revsetsfile = sys.stdin
85 revsetsfile = sys.stdin
76 if len(sys.argv) > 2:
86 if options.file:
77 revsetsfile = open(sys.argv[2])
87 revsetsfile = open(options.file)
78
88
79 revsets = [l.strip() for l in revsetsfile]
89 revsets = [l.strip() for l in revsetsfile]
80
90
General Comments 0
You need to be logged in to leave comments. Login now