annotate mozillatry.py @ 50:582f3571ab33 default tip

better help string
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 31 May 2013 19:48:55 -0700
parents ca72b5866da1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 """
46
9c3726a3d466 better docstring
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
4 push patches to try server
0
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
49
ca72b5866da1 note TODO item
Jeff Hammel <jhammel@mozilla.com>
parents: 48
diff changeset
7 # TODO:
ca72b5866da1 note TODO item
Jeff Hammel <jhammel@mozilla.com>
parents: 48
diff changeset
8 # it'd be nice to be able to push something from a patch queue
ca72b5866da1 note TODO item
Jeff Hammel <jhammel@mozilla.com>
parents: 48
diff changeset
9
4
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
10 import configuration
25
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
11 import datetime
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 import optparse
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 import os
24
484858dfbc03 add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
14 import shutil
29
ade4262c1c6d oops, need an except clause
Jeff Hammel <jhammel@mozilla.com>
parents: 28
diff changeset
15 import subprocess
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 import sys
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 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
19
33
915e064f2910 comments
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
20 ### methods for hg
915e064f2910 comments
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
21
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 def reset(directory):
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 """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
24 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
25 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
26 assert os.path.exists(hg_dir) and os.path.isdir(hg_dir)
31
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
27
28
faacdfcd8ac9 https://wiki.mozilla.org/Build:TryServer#hg_phases
Jeff Hammel <jhammel@mozilla.com>
parents: 27
diff changeset
28 try:
34
9d8dce82166e suggestion from edmorley
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
29 call(['hg', 'update', '-r', 'tip', '--clean'], cwd=directory)
31
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
30 try:
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
31 # XXX stupid; see
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
32 # https://wiki.mozilla.org/Build:TryServer#hg_phases
48
18643e92c91d hg phases text -> /dev/null
Jeff Hammel <jhammel@mozilla.com>
parents: 47
diff changeset
33 call(['hg', 'phase', '-f', '--draft', 'qbase:tip'], cwd=directory, stdout=subprocess.PIPE)
31
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
34 except subprocess.CalledProcessError:
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
35 pass
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
36 call(['hg', 'qpop', '--all'], cwd=directory)
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
37 patches = os.path.join(hg_dir, 'patches')
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
38 if os.path.exists(patches):
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
39 # remove patches
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
40 shutil.rmtree(patches)
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
41 except:
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
42 sys.stderr.write("Directory: %s\n" % directory)
864172062af7 become religious
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
43 raise
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
44
24
484858dfbc03 add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
45 def update_repo(directory):
484858dfbc03 add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
46 """update an hg repository"""
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
47 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
48 reset(directory)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
49 call(['hg', 'pull'], cwd=directory)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
50 call(['hg', 'update'], cwd=directory)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
51 call(['hg', 'qinit'], cwd=directory)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
52
43
3a78de4d900d stub method for importing patches
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
53 def apply_patches(directory, *patches):
3a78de4d900d stub method for importing patches
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
54 """apply patches to an hg repository"""
3a78de4d900d stub method for importing patches
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
55
3a78de4d900d stub method for importing patches
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
56 update_repo(directory)
3a78de4d900d stub method for importing patches
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
57
3a78de4d900d stub method for importing patches
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
58 for patch in patches:
44
6d130b5ddd33 make sure to push the patch
Jeff Hammel <jhammel@mozilla.com>
parents: 43
diff changeset
59 call(['hg', 'qimport', patch, '--push'], cwd=directory)
33
915e064f2910 comments
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
60
915e064f2910 comments
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
61 ### methods for try
915e064f2910 comments
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
62
24
484858dfbc03 add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
63 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
64 """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
65
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
66 # 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
67 if update:
484858dfbc03 add some options so this is more consumable
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
68 update_repo(repo)
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
69
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
70 try:
25
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
71
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
72 # 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
73 if not patches and not update:
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
74 hg_dir = os.path.join(repo, '.hg')
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
75 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
76 patches_dir = os.path.join(hg_dir, 'patches')
bd358da5c346 this is getting out of hand
Jeff Hammel <jhammel@mozilla.com>
parents: 26
diff changeset
77 if os.path.exists(patches_dir):
bd358da5c346 this is getting out of hand
Jeff Hammel <jhammel@mozilla.com>
parents: 26
diff changeset
78 shutil.rmtree(patches_dir)
25
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
79 call(['hg', 'qinit'], cwd=repo)
295112b3e143 taming that beast that is hg
Jeff Hammel <jhammel@mozilla.com>
parents: 24
diff changeset
80 # 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
81 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
82
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
83 # apply patches
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
84 for patch in patches:
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
85 call(['hg', 'qimport', patch], cwd=repo)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
86 call(['hg', 'qpush', '--all'], cwd=repo)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
87 call(['hg', 'qseries', '-v'], cwd=repo)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
88
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
89 # push to try
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
90 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
91 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
92 finally:
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
93 reset(repo)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
94
21
0cac33b7682a forgot the very important platform variable
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
95 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
96 """
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
97 return try syntax; see also:
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
98 - https://github.com/pbiggar/trychooser
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
99 - http://trychooser.pub.build.mozilla.org/
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
100 """
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
101
39
0895e61753d1 better messages
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
102 assert opt or debug, "At least one of `opt` or `debug` must be true"
0895e61753d1 better messages
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
103 assert platforms, "No platforms specified"
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
104 message = ['try:']
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
105 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
106 message += ['-p', ','.join(platforms)]
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
107 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
108 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
109 if bug:
6
6f35d0d90c64 move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
110 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
111 return ' '.join(message)
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
112
7
51d1167cc684 something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
113 ### configuration parsing
51d1167cc684 something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
114
51d1167cc684 something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
115 class ConfigurationError(Exception):
51d1167cc684 something still wrong here but on the right track, i hope
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
116 """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
117
4
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
118 class MozillaTryConfiguration(configuration.Configuration):
5
416f4562005c more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
119
32
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
120 # default configuration file
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
121 # TODO: upstream the pattern to configuration but with default_config_file = None
18
328e88120fc2 change default config file path to just .mozutils
Jeff Hammel <jhammel@mozilla.com>
parents: 17
diff changeset
122 default_config_file = os.path.join('~', '.mozutils')
5
416f4562005c more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
123 usage = '%prog [options] patch <patch2> <...>'
9
8c8a223e4df2 begin to read config file
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
124 load_help = 'load from config file'
8c8a223e4df2 begin to read config file
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
125 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
126 load_help += ' [DEFAULT: %s]' % default_config_file
32
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
127
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
128 # configuration options
4
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
129 options = {'opt': {'default': True,
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
130 'help': "whether to try on opt builds"},
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
131 'debug': {'default': True,
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
132 'help': "whether to try on debug builds"},
21
0cac33b7682a forgot the very important platform variable
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
133 'platforms': {'default': [],
50
582f3571ab33 better help string
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
134 'help': "platforms to run on, 'all' if not specified",
23
4016b1d28c79 command line switches
Jeff Hammel <jhammel@mozilla.com>
parents: 22
diff changeset
135 "flags": ["-p", "--platform"]},
4
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
136 'unittests': {'default': [],
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
137 'help': "unit tests to run",
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
138 'flags': ['-u', '--unittests']},
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
139 'talostests': {'default': [],
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
140 'help': "talos tests to run",
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
141 'flags': ['-t', '--talostests']},
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
142 'mozilla_central': {'help': "path to mozilla-central clone",
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
143 'required': True,
32
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
144 'flags': ["--m-c", "--mozilla-central"]},
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
145 'bug': {'help': "bug number to post try results to",
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
146 'type': int,
daf7c333e01c add bug to options
Jeff Hammel <jhammel@mozilla.com>
parents: 31
diff changeset
147 'flags': ['-b', '--bug']}
4
14275dcbff10 begin switching to configuration package
Jeff Hammel <jhammel@mozilla.com>
parents: 3
diff changeset
148 }
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
149
20
8587528177b4 begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
150 # configuration items to interpolate as paths
8587528177b4 begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
151 paths = ['mozilla_central']
8587528177b4 begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
152
37
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
153 @classmethod
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
154 def main(cls, args=sys.argv[1:]):
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
155 instance = cls()
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
156 options, args = instance.parse_args()
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
157 if not args:
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
158 instance.print_usage()
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
159 instance.exit()
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
160 return instance, options, args
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
161
5
416f4562005c more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
162 def __init__(self):
6
6f35d0d90c64 move more to configuration land
Jeff Hammel <jhammel@mozilla.com>
parents: 5
diff changeset
163 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
164
8
7423fa8b4343 wrong function name
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
165 def validate(self):
5
416f4562005c more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
166 """check configuration"""
416f4562005c more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
167
8
7423fa8b4343 wrong function name
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
168 configuration.Configuration.validate(self)
7423fa8b4343 wrong function name
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
169
7423fa8b4343 wrong function name
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
170 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
171 raise ConfigurationError("Must have opt or debug builds")
5
416f4562005c more switching to configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents: 4
diff changeset
172
20
8587528177b4 begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
173 for path in self.paths:
8587528177b4 begin to separate out path handling
Jeff Hammel <jhammel@mozilla.com>
parents: 18
diff changeset
174 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
175
14
06b8783eae81 move another check to validate
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
176 try_directory = self.config.get('mozilla_central')
06b8783eae81 move another check to validate
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
177 if (try_directory is None) or (not os.path.exists(try_directory)):
15
Jeff Hammel <jhammel@mozilla.com>
parents: 14
diff changeset
178 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
179
40
efb29cff39a7 hopefully fix platforms issue
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
180 if not self.config.get('platforms'):
efb29cff39a7 hopefully fix platforms issue
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
181 self.config['platforms'] = ['all']
efb29cff39a7 hopefully fix platforms issue
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
182
11
9b90cf893943 default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
183 def configuration_files(self, options, args):
12
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
184 configuration_files = configuration.Configuration.configuration_files(self, options, args)
11
9b90cf893943 default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
185 if not configuration_files:
12
Jeff Hammel <jhammel@mozilla.com>
parents: 11
diff changeset
186 default_config = os.path.expanduser(self.default_config_file)
11
9b90cf893943 default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
187 if os.path.exists(default_config):
9b90cf893943 default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
188 configuration_files = [default_config]
9b90cf893943 default configuration file
Jeff Hammel <jhammel@mozilla.com>
parents: 10
diff changeset
189 return configuration_files
1
0f8e4a3b4e1c split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
190
13
1e90d869f787 only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
191 def load_configuration_file(self, filename):
1e90d869f787 only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
192 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
193
1e90d869f787 only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
194 # 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
195 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
196 if key in self.option_dict])
1e90d869f787 only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
197 return config
1e90d869f787 only use the configuration values we need
Jeff Hammel <jhammel@mozilla.com>
parents: 12
diff changeset
198
36
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
199 ### methods for try on mozilla-central
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
200
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
201 def try_syntax(self):
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
202 return try_syntax(opt=self.config.get('opt'),
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
203 debug=self.config.get('debug'),
40
efb29cff39a7 hopefully fix platforms issue
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
204 platforms=self.config.get('platforms'),
36
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
205 unittests=self.config.get('unittests', []),
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
206 talos=self.config.get('talostests', []),
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
207 bug=self.config.get('bug'))
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
208
37
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
209 def push_to_try(self, patches, commit=None, repo=None):
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
210 assert patches
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
211 if commit is None:
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
212 commit = self.try_syntax()
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
213 repo = repo or self.config['mozilla_central']
47
8a76eb02a3ef correct minor errors
Jeff Hammel <jhammel@mozilla.com>
parents: 46
diff changeset
214 push_to_try(patches=patches, repo=repo, commit=commit)
37
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
215
1
0f8e4a3b4e1c split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
216 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
217
0f8e4a3b4e1c split add_options to its own method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
218 # parse command line arguments
47
8a76eb02a3ef correct minor errors
Jeff Hammel <jhammel@mozilla.com>
parents: 46
diff changeset
219 mozillatry, options, patches = MozillaTryConfiguration.main(args)
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
220
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
221 # 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
222 try_directory = options.mozilla_central
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
223
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
224 # build try syntax
36
3a7e8aa80328 move this to an instance method for consumption
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
225 commit = mozillatry.try_syntax()
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
226 print commit
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
227
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
228 # push to try
37
cbf6ec238952 another convenience method
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
229 mozillatry.push_to_try(patches, commit=commit)
0
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
230
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
231 if __name__ == '__main__':
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
232 main()
df6a8049e9a4 initial port from http://k0s.org/mozilla/try.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
233