Mercurial > mozilla > hg > MozillaTry
annotate mozillatry.py @ 28:faacdfcd8ac9
https://wiki.mozilla.org/Build:TryServer#hg_phases
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 Dec 2012 11:52:30 -0800 |
parents | bd358da5c346 |
children | ade4262c1c6d |
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 |
4
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
7 import configuration |
25
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
8 import datetime |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 import optparse |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 import os |
24
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
11 import shutil |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 import sys |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 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
|
15 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 def reset(directory): |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 """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
|
18 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
|
19 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
|
20 assert os.path.exists(hg_dir) and os.path.isdir(hg_dir) |
24
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
21 patches = os.path.join(hg_dir, 'patches') |
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
22 if os.path.exists(patches): |
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
23 shutil.rmtree(patches) |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 call(['hg', 'revert', '--no-backup', '--all'], cwd=directory) |
28
faacdfcd8ac9
https://wiki.mozilla.org/Build:TryServer#hg_phases
Jeff Hammel <jhammel@mozilla.com>
parents:
27
diff
changeset
|
25 try: |
faacdfcd8ac9
https://wiki.mozilla.org/Build:TryServer#hg_phases
Jeff Hammel <jhammel@mozilla.com>
parents:
27
diff
changeset
|
26 # XXX stupid; see |
faacdfcd8ac9
https://wiki.mozilla.org/Build:TryServer#hg_phases
Jeff Hammel <jhammel@mozilla.com>
parents:
27
diff
changeset
|
27 # https://wiki.mozilla.org/Build:TryServer#hg_phases |
faacdfcd8ac9
https://wiki.mozilla.org/Build:TryServer#hg_phases
Jeff Hammel <jhammel@mozilla.com>
parents:
27
diff
changeset
|
28 call(['hg', 'phase', '-f', '--draft', 'qbase:tip'], cwd=directory) |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 call(['hg', 'qpop', '--all'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 try: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 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
|
32 except: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 pass |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 |
24
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
35 def update_repo(directory): |
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
36 """update an hg repository""" |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
37 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
|
38 reset(directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 call(['hg', 'pull'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 call(['hg', 'update'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 call(['hg', 'qinit'], cwd=directory) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
42 |
24
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
43 def push_to_try(patches, repo, commit, _try='ssh://hg.mozilla.org/try/', update=True): |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
44 """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
|
45 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
46 # ensure the repo is in a good state |
24
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
47 if update: |
484858dfbc03
add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents:
23
diff
changeset
|
48 update_repo(repo) |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 try: |
25
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
51 |
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
52 # if no patches given and not updating, commit what you have |
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
53 if not patches and not update: |
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
54 hg_dir = os.path.join(repo, '.hg') |
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
55 assert os.path.exists(hg_dir) and os.path.isdir(hg_dir) |
27
bd358da5c346
this is getting out of hand
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
56 patches_dir = os.path.join(hg_dir, 'patches') |
bd358da5c346
this is getting out of hand
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
57 if os.path.exists(patches_dir): |
bd358da5c346
this is getting out of hand
Jeff Hammel <jhammel@mozilla.com>
parents:
26
diff
changeset
|
58 shutil.rmtree(patches_dir) |
25
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
59 call(['hg', 'qinit'], cwd=repo) |
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
60 # TODO: ensure there's something to commit |
26
fa1215cee8c4
abort: ":" cannot be used in the name of a patch
Jeff Hammel <jhammel@mozilla.com>
parents:
25
diff
changeset
|
61 call(['hg', 'qnew', datetime.datetime.now().strftime("%Y%m%d%H%M%S")], cwd=repo) |
25
295112b3e143
taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
62 |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
63 # apply patches |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 for patch in patches: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
65 call(['hg', 'qimport', patch], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
66 call(['hg', 'qpush', '--all'], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
67 call(['hg', 'qseries', '-v'], cwd=repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
68 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
69 # push to try |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
70 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
|
71 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
|
72 finally: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
73 reset(repo) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
74 |
21
0cac33b7682a
forgot the very important platform variable
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
75 def try_syntax(opt=True, debug=True, platforms=('all',), unittests=('all',), talos=('all',), bug=None): |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
76 """ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
77 return try syntax; see also: |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
78 - https://github.com/pbiggar/trychooser |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
79 - http://trychooser.pub.build.mozilla.org/ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
80 """ |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
81 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
82 assert opt or debug |
21
0cac33b7682a
forgot the very important platform variable
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
83 assert platforms |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
84 message = ['try:'] |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
85 message += ['-b', '%s%s' % (('d' if debug else ''), ('o' if opt else ''))] |
21
0cac33b7682a
forgot the very important platform variable
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
86 message += ['-p', ','.join(platforms)] |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
87 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
|
88 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
|
89 if bug: |
6
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
90 message += ['--post-to-bugzilla', 'Bug', str(bug)] |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
91 return ' '.join(message) |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
92 |
7
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
93 ### configuration parsing |
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
94 |
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
95 class ConfigurationError(Exception): |
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
96 """error when checking configuration""" |
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
97 |
4
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
98 class MozillaTryConfiguration(configuration.Configuration): |
5
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
99 |
18
328e88120fc2
change default config file path to just .mozutils
Jeff Hammel <jhammel@mozilla.com>
parents:
17
diff
changeset
|
100 default_config_file = os.path.join('~', '.mozutils') |
5
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
101 usage = '%prog [options] patch <patch2> <...>' |
9 | 102 load_help = 'load from config file' |
103 if os.path.exists(os.path.expanduser(default_config_file)): | |
10
f0bca08e296a
start looking for config file
Jeff Hammel <jhammel@mozilla.com>
parents:
9
diff
changeset
|
104 load_help += ' [DEFAULT: %s]' % default_config_file |
4
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
105 options = {'opt': {'default': True, |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
106 'help': "whether to try on opt builds"}, |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
107 'debug': {'default': True, |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
108 'help': "whether to try on debug builds"}, |
21
0cac33b7682a
forgot the very important platform variable
Jeff Hammel <jhammel@mozilla.com>
parents:
20
diff
changeset
|
109 'platforms': {'default': [], |
23 | 110 'help': "platforms to run on", |
111 "flags": ["-p", "--platform"]}, | |
4
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
112 'unittests': {'default': [], |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
113 'help': "unit tests to run", |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
114 'flags': ['-u', '--unittests']}, |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
115 'talostests': {'default': [], |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
116 'help': "talos tests to run", |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
117 'flags': ['-t', '--talostests']}, |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
118 'mozilla_central': {'help': "path to mozilla-central clone", |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
119 'required': True, |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
120 'flags': ["--m-c", "--mozilla-central"]} |
14275dcbff10
begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents:
3
diff
changeset
|
121 } |
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
|
122 |
20
8587528177b4
begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
123 # configuration items to interpolate as paths |
8587528177b4
begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
124 paths = ['mozilla_central'] |
8587528177b4
begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
125 |
5
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
126 def __init__(self): |
6
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
127 configuration.Configuration.__init__(self, usage=self.usage, load='--config') |
5
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
128 |
8 | 129 def validate(self): |
5
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
130 """check configuration""" |
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
131 |
8 | 132 configuration.Configuration.validate(self) |
133 | |
134 if (not self.config.get('opt')) and (not self.config.get('debug')): | |
7
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
135 raise ConfigurationError("Must have opt or debug builds") |
5
416f4562005c
more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
4
diff
changeset
|
136 |
20
8587528177b4
begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
137 for path in self.paths: |
8587528177b4
begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
138 self.config[path] = os.path.expanduser(self.config[path]) |
8587528177b4
begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
139 |
14
06b8783eae81
move another check to validate
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
140 try_directory = self.config.get('mozilla_central') |
06b8783eae81
move another check to validate
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
141 if (try_directory is None) or (not os.path.exists(try_directory)): |
15 | 142 raise ConfigurationError("mozilla-central directory does not exist: %s" % try_directory) |
14
06b8783eae81
move another check to validate
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
143 |
16 | 144 # TODO: make a 'path' type |
145 | |
11
9b90cf893943
default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
146 def configuration_files(self, options, args): |
12 | 147 configuration_files = configuration.Configuration.configuration_files(self, options, args) |
11
9b90cf893943
default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
148 if not configuration_files: |
12 | 149 default_config = os.path.expanduser(self.default_config_file) |
11
9b90cf893943
default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
150 if os.path.exists(default_config): |
9b90cf893943
default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
151 configuration_files = [default_config] |
9b90cf893943
default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents:
10
diff
changeset
|
152 return configuration_files |
1
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
153 |
13
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
154 def load_configuration_file(self, filename): |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
155 config = configuration.Configuration.load_configuration_file(self, filename) |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
156 |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
157 # ignore options that we don't care about |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
158 config = dict([(key, value) for key, value in config.items() |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
159 if key in self.option_dict]) |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
160 return config |
1e90d869f787
only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents:
12
diff
changeset
|
161 |
1
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
162 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
|
163 |
0f8e4a3b4e1c
split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
164 # parse command line arguments |
6
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
165 parser = MozillaTryConfiguration() |
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
166 options, args = parser.parse_args() |
7
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
167 if not args: |
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
168 parser.print_usage() |
51d1167cc684
something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents:
6
diff
changeset
|
169 parser.exit() |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
170 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
171 # get mozilla-central repository directory |
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
|
172 try_directory = options.mozilla_central |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
173 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
174 # build try syntax |
6
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
175 commit = try_syntax(opt=options.opt, |
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
176 debug=options.debug, |
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
177 unittests=options.unittests, |
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
178 talos=options.talostests |
6f35d0d90c64
move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents:
5
diff
changeset
|
179 ) |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
180 print commit |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
181 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
182 # push to try |
14
06b8783eae81
move another check to validate
Jeff Hammel <jhammel@mozilla.com>
parents:
13
diff
changeset
|
183 push_to_try(patches=args, repo=options.mozilla_central, commit=commit) |
0
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
184 |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
185 if __name__ == '__main__': |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
186 main() |
df6a8049e9a4
initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
187 |