Mercurial > mozilla > hg > MozillaTry
annotate mozillatry.py @ 2:3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 01 Dec 2012 23:05:19 -0800 |
parents | 0f8e4a3b4e1c |
children | 7495c25d8476 |
rev | line source |
---|---|
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 """ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 push patches to try |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 """ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 import optparse |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 import os |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 import sys |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 from subprocess import check_call as call |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 def reset(directory): |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 """reset an hg directory to a good state""" |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 assert os.path.exists(directory) and os.path.isdir(directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 hg_dir = os.path.join(directory, '.hg') |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 assert os.path.exists(hg_dir) and os.path.isdir(hg_dir) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 call(['hg', 'revert', '--no-backup', '--all'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 call(['hg', 'qpop', '--all'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 try: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 shutil.rmtree(os.path.join(hg_dir, 'patches')) # remove patches |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 except: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 pass |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 def update(directory): |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 """update a mozilla-central checkout""" |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
27 assert os.path.exists(directory) and os.path.isdir(directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
28 reset(directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 call(['hg', 'pull'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 call(['hg', 'update'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 call(['hg', 'qinit'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
32 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 def push_to_try(patches, repo, commit, _try='ssh://hg.mozilla.org/try/'): |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 """push a series of patches to try repository""" |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
36 # ensure the repo is in a good state |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
37 update(repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
38 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 try: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 # apply patches |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 for patch in patches: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
42 call(['hg', 'qimport', patch], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
43 call(['hg', 'qpush', '--all'], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
44 call(['hg', 'qseries', '-v'], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
45 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
46 # push to try |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
47 call(['hg', 'qref', '--message', commit], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
48 call(['hg', 'push', '-f', _try], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 finally: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 reset(repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 def try_syntax(opt=True, debug=True, unittests=('all'), talos=('all'), bug=None): |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
53 """ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
54 return try syntax; see also: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
55 - https://github.com/pbiggar/trychooser |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 - http://trychooser.pub.build.mozilla.org/ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
57 """ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
59 assert opt or debug |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
60 message = ['try:'] |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
61 message += ['-b', '%s%s' % (('d' if debug else ''), ('o' if opt else ''))] |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
62 message += ['-u', (','.join(unittests) if unittests else 'none')] |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
63 message += ['-t', (','.join(talos) if talos else 'none')] |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 if bug: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
65 message += ['--post-to-bugzilla', str(bug)] |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
66 return ' '.join(message) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
67 |
1
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
68 def add_options(parser): |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
69 """add options for mozilla try to an OptionParser instance""" |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
70 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
71 parser.add_option('--no-opt', dest='opt', |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
72 action='store_false', default=True, |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
73 help='no opt builds') |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
74 parser.add_option('--no-debug', dest='debug', |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
75 action='store_false', default=True, |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
76 help='no debug builds') |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
77 parser.add_option('-u', dest='unittests', action='append', |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
78 help='unittests') |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
79 parser.add_option('-t', dest='talos', action='append', |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
80 help='talos tests') |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
81 parser.add_option('--bug', dest='bug', type='int', |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
82 help='post to bugzilla bug #') |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
83 parser.add_option('-c', '--config', dest='config', |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
84 default=os.path.join(os.environ['HOME'], '.mozutils.ini'), |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
85 help='location of config file') |
2
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
86 parser.add_option('-m', '--m-c', '--mozilla-central', |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
87 help="path to mozilla-central repository") |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
88 |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
89 |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
90 def read_config(filename, options): |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
91 """read .mozutils config file and substitute for options if None""" |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
92 |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
93 # XXX stub; this should really use |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
94 # e.g. http://k0s.org/mozilla/hg/configuration/ |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
95 from ConfigParser import ConfigParser |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
96 parser = ConfigParser() |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
97 parser.read(filename) |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
98 if options.mozilla_central is None: |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
99 try: |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
100 path = parser.get('hg', 'mozilla-central') |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
101 os.path.expanduser(path) |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
102 except Exception: # XXX temporary hack |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
103 pass |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
104 return parser |
1
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
105 |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
106 |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
107 def main(args=sys.argv[1:]): |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
108 |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
109 # parse command line arguments |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
110 usage = '%prog [options] patch <patch2> <...>' |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
111 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
112 """description formatter""" |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
113 def format_description(self, description): |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
114 description = description.strip() |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
115 if description: |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
116 return description + '\n' |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
117 else: |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
118 return '' |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
119 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
120 add_options(parser) |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
121 options, args = parser.parse_args(args) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
122 if not args: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
123 parser.print_help() |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
124 parser.exit() |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
125 if (not options.opt) and (not options.debug): |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
126 parser.error("Must enable opt or debug builds") |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
127 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
128 # get mozilla-central repository directory |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
129 config_file = options.__dict__.pop('config') |
2
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
130 if os.path.exists(config_file): |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
131 read_config(config_file) |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
132 try_directory = options.mozilla_central |
3eaee0d10880
make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now
Jeff Hammel <jhammel@mozilla.com>
parents:
1
diff
changeset
|
133 if (try_directory is None) or (not os.path.exists(try_directory)): |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
134 parser.error("mozilla-central try directory does not exist: %s" % try_directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
135 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
136 # build try syntax |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
137 commit = try_syntax(**options.__dict__) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
138 print commit |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
139 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
140 # push to try |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
141 push_to_try(patches=args, repo=try_directory, commit=commit) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
142 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
143 if __name__ == '__main__': |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
144 main() |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
145 |