OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
(...skipping 16 matching lines...) Expand all Loading... |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 import json | 29 import json |
30 import optparse | 30 import optparse |
31 import os | 31 import os |
32 import re | 32 import re |
33 import sys | 33 import sys |
34 import urllib | 34 import urllib |
35 | 35 |
36 from common_includes import * | 36 from common_includes import * |
| 37 import push_to_trunk |
| 38 from push_to_trunk import PushToTrunkOptions |
| 39 from push_to_trunk import RunPushToTrunk |
37 | 40 |
38 SETTINGS_LOCATION = "SETTINGS_LOCATION" | 41 SETTINGS_LOCATION = "SETTINGS_LOCATION" |
39 | 42 |
40 CONFIG = { | 43 CONFIG = { |
41 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", | 44 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", |
42 DOT_GIT_LOCATION: ".git", | 45 DOT_GIT_LOCATION: ".git", |
43 SETTINGS_LOCATION: "~/.auto-roll", | 46 SETTINGS_LOCATION: "~/.auto-roll", |
44 } | 47 } |
45 | 48 |
46 | 49 |
47 class AutoRollOptions(CommonOptions): | 50 class AutoRollOptions(CommonOptions): |
48 def __init__(self, options): | 51 def __init__(self, options): |
49 super(AutoRollOptions, self).__init__(options) | 52 super(AutoRollOptions, self).__init__(options) |
50 self.requires_editor = False | 53 self.requires_editor = False |
51 self.status_password = options.status_password | 54 self.status_password = options.status_password |
| 55 self.r = options.r |
| 56 self.c = options.c |
| 57 self.push = getattr(options, 'push', False) |
52 | 58 |
53 | 59 |
54 class Preparation(Step): | 60 class Preparation(Step): |
55 MESSAGE = "Preparation." | 61 MESSAGE = "Preparation." |
56 | 62 |
57 def RunStep(self): | 63 def RunStep(self): |
58 self.InitialEnvironmentChecks() | 64 self.InitialEnvironmentChecks() |
59 self.CommonPrepare() | 65 self.CommonPrepare() |
60 | 66 |
61 | 67 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 self.RestoreIfUnset("lkgr") | 149 self.RestoreIfUnset("lkgr") |
144 self.RestoreIfUnset("tree_message") | 150 self.RestoreIfUnset("tree_message") |
145 latest = int(self._state["latest"]) | 151 latest = int(self._state["latest"]) |
146 lkgr = int(self._state["lkgr"]) | 152 lkgr = int(self._state["lkgr"]) |
147 if latest == lkgr: | 153 if latest == lkgr: |
148 print "ToT (r%d) is clean. Pushing to trunk." % latest | 154 print "ToT (r%d) is clean. Pushing to trunk." % latest |
149 self.PushTreeStatus("Tree is closed (preparing to push)") | 155 self.PushTreeStatus("Tree is closed (preparing to push)") |
150 | 156 |
151 # TODO(machenbach): Call push to trunk script. | 157 # TODO(machenbach): Call push to trunk script. |
152 # TODO(machenbach): Update the script before calling it. | 158 # TODO(machenbach): Update the script before calling it. |
153 # self._side_effect_handler.Command( | 159 try: |
154 # "tools/push-to-trunk/push-to-trunk.py", | 160 if self._options.push: |
155 # "-f -c %s -r %s" % (self._options.c, self._options.r)) | 161 self._side_effect_handler.Call( |
156 self.PushTreeStatus(self._state["tree_message"]) | 162 RunPushToTrunk, |
| 163 push_to_trunk.CONFIG, |
| 164 PushToTrunkOptions.MakeForcedOptions(self._options.r, |
| 165 self._options.c), |
| 166 self._side_effect_handler) |
| 167 finally: |
| 168 self.PushTreeStatus(self._state["tree_message"]) |
157 else: | 169 else: |
158 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." | 170 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." |
159 % (latest, lkgr)) | 171 % (latest, lkgr)) |
160 | 172 |
161 | 173 |
162 def RunAutoRoll(config, | 174 def RunAutoRoll(config, |
163 options, | 175 options, |
164 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 176 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
165 step_classes = [ | 177 step_classes = [ |
166 Preparation, | 178 Preparation, |
167 CheckAutoRollSettings, | 179 CheckAutoRollSettings, |
168 CheckTreeStatus, | 180 CheckTreeStatus, |
169 FetchLatestRevision, | 181 FetchLatestRevision, |
170 CheckLastPush, | 182 CheckLastPush, |
171 FetchLKGR, | 183 FetchLKGR, |
172 PushToTrunk, | 184 PushToTrunk, |
173 ] | 185 ] |
174 RunScript(step_classes, config, options, side_effect_handler) | 186 RunScript(step_classes, config, options, side_effect_handler) |
175 | 187 |
176 | 188 |
177 def BuildOptions(): | 189 def BuildOptions(): |
178 result = optparse.OptionParser() | 190 result = optparse.OptionParser() |
179 result.add_option("-c", "--chromium", dest="c", | 191 result.add_option("-c", "--chromium", dest="c", |
180 help=("Specify the path to your Chromium src/ " | 192 help=("Specify the path to your Chromium src/ " |
181 "directory to automate the V8 roll.")) | 193 "directory to automate the V8 roll.")) |
| 194 result.add_option("-p", "--push", |
| 195 help="Push to trunk if possible. Dry run if unspecified.", |
| 196 default=False, action="store_true") |
182 result.add_option("-r", "--reviewer", dest="r", | 197 result.add_option("-r", "--reviewer", dest="r", |
183 help=("Specify the account name to be used for reviews.")) | 198 help=("Specify the account name to be used for reviews.")) |
184 result.add_option("-s", "--step", dest="s", | 199 result.add_option("-s", "--step", dest="s", |
185 help="Specify the step where to start work. Default: 0.", | 200 help="Specify the step where to start work. Default: 0.", |
186 default=0, type="int") | 201 default=0, type="int") |
187 result.add_option("--status-password", | 202 result.add_option("--status-password", |
188 help="A file with the password to the status app.") | 203 help="A file with the password to the status app.") |
189 return result | 204 return result |
190 | 205 |
191 | 206 |
192 def Main(): | 207 def Main(): |
193 parser = BuildOptions() | 208 parser = BuildOptions() |
194 (options, args) = parser.parse_args() | 209 (options, args) = parser.parse_args() |
195 if not options.c or not options.r: | 210 if not options.c or not options.r: |
196 print "You need to specify the chromium src location and a reviewer." | 211 print "You need to specify the chromium src location and a reviewer." |
197 parser.print_help() | 212 parser.print_help() |
198 return 1 | 213 return 1 |
199 RunAutoRoll(CONFIG, AutoRollOptions(options)) | 214 RunAutoRoll(CONFIG, AutoRollOptions(options)) |
200 | 215 |
201 if __name__ == "__main__": | 216 if __name__ == "__main__": |
202 sys.exit(Main()) | 217 sys.exit(Main()) |
OLD | NEW |