Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(703)

Side by Side Diff: tools/push-to-trunk/push_to_trunk.py

Issue 49653002: Add push-to-trunk python port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following
11 # disclaimer in the documentation and/or other materials provided
12 # with the distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import datetime
30 import optparse
31 import sys
32 import tempfile
33
34 from common_includes import *
35
36 TRUNKBRANCH = "TRUNKBRANCH"
37 CHROMIUM = "CHROMIUM"
38 DEPS_FILE = "DEPS_FILE"
39
40 CONFIG = {
41 BRANCHNAME: "prepare-push",
42 TRUNKBRANCH: "trunk-push",
43 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile",
44 TEMP_BRANCH: "prepare-push-temporary-branch-created-by-script",
45 DOT_GIT_LOCATION: ".git",
46 VERSION_FILE: "src/version.cc",
47 CHANGELOG_FILE: "ChangeLog",
48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry",
49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch",
50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg",
51 DEPS_FILE: "DEPS",
52 }
53
54
55 class Preparation(Step):
56 def __init__(self):
57 Step.__init__(self, "Preparation.")
58
59 def RunStep(self):
60 self.InitialEnvironmentChecks()
61 self.CommonPrepare()
62 self.DeleteBranch(self.Config(TRUNKBRANCH))
63
64
65 class FreshBranch(Step):
66 def __init__(self):
67 Step.__init__(self, "Create a fresh branch.")
68
69 def RunStep(self):
70 args = "checkout -b %s svn/bleeding_edge" % self.Config(BRANCHNAME)
71 if self.Git(args) is None:
72 self.Die("Creating branch %s failed." % self.Config(BRANCHNAME))
73
74
75 class DetectLastPush(Step):
76 def __init__(self):
77 Step.__init__(self, "Detect commit ID of last push to trunk.")
78
79 def RunStep(self):
80 last_push = (self._options.l or
81 self.Git("log -1 --format=%H ChangeLog").strip())
82 loop = 1
Jakob Kummerow 2013/11/06 16:37:23 Let's make this a bit more Pythonic. s/loop = 1//
Michael Achenbach 2013/11/07 15:56:46 Done. I tried to stay really close to the bash ;)
83 while loop == 1:
84 # Print assumed commit, circumventing git's pager.
85 print self.Git("log -1 %s" % last_push)
86 if self.Confirm("Is the commit printed above the last push to trunk?"):
87 loop = 0
88 else:
89 args = "log -1 --format=%H %s^ ChangeLog" % last_push
90 last_push = self.Git(args).strip()
91 self.Persist("last_push", last_push)
92 self._state["last_push"] = last_push
93
94
95 class PrepareChangeLog(Step):
96 def __init__(self):
97 Step.__init__(self, "Prepare raw ChangeLog entry.")
98
99 def RunStep(self):
100 self.RestoreIfUnset("last_push")
101
102 # These version numbers are used again later for the trunk commit.
103 self.ReadAndPersistVersion()
104
105 date = datetime.date.today().strftime("%Y-%m-%d")
106 self.Persist("date", date)
107 output = "%s: Version %s.%s.%s\n\n" % (date,
108 self._state["major"],
109 self._state["minor"],
110 self._state["build"])
111 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
112
113 args = "log %s..HEAD --format=%%H" % self._state["last_push"]
114 commits = self.Git(args).strip()
115 for commit in commits.splitlines():
116 # Get the commit's title line.
117 args = "log -1 %s --format=\"%%w(80,8,8)%%s\"" % commit
118 title = "%s\n" % self.Git(args).rstrip()
119 AppendToFile(title, self.Config(CHANGELOG_ENTRY_FILE))
120
121 # Grep for "BUG=xxxx" lines in the commit message and convert them to
122 # "(issue xxxx)".
123 out = self.Git("log -1 %s --format=\"%%B\"" % commit).splitlines()
124 out = filter(lambda x: re.search(r"^BUG=", x), out)
125 out = filter(lambda x: not re.search(r"BUG=$", x), out)
126 out = filter(lambda x: not re.search(r"BUG=none$", x), out)
127
128 def FormatIssue(text):
129 text = MSub(r"BUG=v8:(.*)$", r"issue \1", text)
Jakob Kummerow 2013/11/06 16:37:23 Why do we need multiline substitution...
Michael Achenbach 2013/11/07 15:56:46 Well...
130 text = MSub(r"BUG=chromium:(.*)$", r"Chromium issue \1", text)
131 text = MSub(r"BUG=(.*)$", r"Chromium issue \1", text)
132 return " %s\n" % text
133
134 for line in map(FormatIssue, out):
Jakob Kummerow 2013/11/06 16:37:23 ...if we're mapping the function onto every line?
Michael Achenbach 2013/11/07 15:56:46 ... we don't. That whole thing here could probably
135 AppendToFile(line, self.Config(CHANGELOG_ENTRY_FILE))
136
137 # Append the commit's author for reference.
138 args = "log -1 %s --format=\"%%w(80,8,8)(%%an)\"" % commit
139 author = self.Git(args).rstrip()
140 AppendToFile("%s\n\n" % author, self.Config(CHANGELOG_ENTRY_FILE))
141
142 msg = " Performance and stability improvements on all platforms.\n"
143 AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE))
144
145 class EditChangeLog(Step):
146 def __init__(self):
147 Step.__init__(self, "Edit ChangeLog entry.")
148
149 def RunStep(self):
150 print ("Please press <Return> to have your EDITOR open the ChangeLog "
151 "entry, then edit its contents to your liking. When you're done, "
152 "save the file and exit your EDITOR. ")
153 self.ReadLine()
154
155 self.Editor(self.Config(CHANGELOG_ENTRY_FILE))
156 handle, new_changelog = tempfile.mkstemp()
157 os.close(handle)
158
159 # Eliminate any trailing newlines by going through a shell variable.
Jakob Kummerow 2013/11/06 16:37:23 outdated
Michael Achenbach 2013/11/07 15:56:46 Done.
160 # Also (1) eliminate tabs, (2) fix too little and (3) too much indentation,
161 # and (4) eliminate trailing whitespace.
162 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip()
163 changelog_entry = MSub(r"\t", r" ", changelog_entry)
164 changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1", changelog_entry)
165 changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1", changelog_entry)
166 changelog_entry = MSub(r" +$", r"", changelog_entry)
167
168 if changelog_entry == "":
169 self.Die("Empty ChangeLog entry.")
170
171 with open(new_changelog, "w") as f:
172 f.write(changelog_entry)
173 f.write("\n\n\n") # Explicitly insert two empty lines.
174
175 AppendToFile(FileToText(self.Config(CHANGELOG_FILE)), new_changelog)
176 TextToFile(FileToText(new_changelog), self.Config(CHANGELOG_FILE))
177 os.remove(new_changelog)
178
179
180 class IncrementVersion(Step):
181 def __init__(self):
182 Step.__init__(self, "Increment version number.")
183
184 def RunStep(self):
185 self.RestoreIfUnset("build")
186 new_build = str(int(self._state["build"]) + 1)
187
188 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
189 "fire up your EDITOR on %s so you can make arbitrary "
190 "changes. When you're done, save the file and exit your "
191 "EDITOR.)" % self.Config(VERSION_FILE))):
192 text = FileToText(self.Config(VERSION_FILE))
193 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
194 r"\g<space>%s" % new_build,
195 text)
196 TextToFile(text, self.Config(VERSION_FILE))
197 else:
198 self.Editor(self.Config(VERSION_FILE))
199
200 self.ReadAndPersistVersion("new_")
201
202
203 class CommitLocal(Step):
204 def __init__(self):
205 Step.__init__(self, "Commit to local branch.")
206
207 def RunStep(self):
208 self.RestoreVersionIfUnset("new_")
209 prep_commit_msg = ("Prepare push to trunk. "
210 "Now working on version %s.%s.%s." % (self._state["new_major"],
211 self._state["new_minor"],
212 self._state["new_build"]))
213 self.Persist("prep_commit_msg", prep_commit_msg)
214 if self.Git("commit -a -m \"%s\"" % prep_commit_msg) is None:
215 self.Die("'git commit -a' failed.")
216
217
218 class CommitRepository(Step):
219 def __init__(self):
220 Step.__init__(self, "Commit to the repository.")
221
222 def RunStep(self):
223 self.WaitForLGTM()
224 # Re-read the ChangeLog entry (to pick up possible changes).
225 TextToFile(Command("cat %s | awk --posix '{\
Jakob Kummerow 2013/11/06 16:37:23 Don't you want to route this command through Step.
Michael Achenbach 2013/11/07 15:56:46 Since it has no side effects and since it is quite
226 if ($0 ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}:/) {\
227 if (in_firstblock == 1) {\
228 exit 0;\
229 } else {\
230 in_firstblock = 1;\
231 }\
232 };\
233 print $0;\
234 }'" % self.Config(CHANGELOG_FILE)), self.Config(CHANGELOG_ENTRY_FILE))
235
236 if self.Git("cl dcommit", "PRESUBMIT_TREE_CHECK=\"skip\"") is None:
237 self.Die("'git cl dcommit' failed, please try again.")
238
239
240 class StragglerCommits(Step):
241 def __init__(self):
242 Step.__init__(self, "Fetch straggler commits that sneaked in since this "
243 "script was started.")
244
245 def RunStep(self):
246 if self.Git("svn fetch") is None:
247 self.Die("'git svn fetch' failed.")
248 self.Git("checkout svn/bleeding_edge")
249 self.RestoreIfUnset("prep_commit_msg")
250 args = "log -1 --format=%%H --grep=\"%s\"" % self._state["prep_commit_msg"]
251 prepare_commit_hash = self.Git(args).strip()
252 self.Persist("prepare_commit_hash", prepare_commit_hash)
253
254
255 class SquashCommits(Step):
256 def __init__(self):
257 Step.__init__(self, "Squash commits into one.")
258
259 def RunStep(self):
260 # Instead of relying on "git rebase -i", we'll just create a diff, because
261 # that's easier to automate.
262 self.RestoreIfUnset("prepare_commit_hash")
263 args = "diff svn/trunk %s" % self._state["prepare_commit_hash"]
264 TextToFile(self.Git(args), self.Config(PATCH_FILE))
265
266 # Convert the ChangeLog entry to commit message format:
267 # - remove date
268 # - remove indentation
269 # - merge paragraphs into single long lines, keeping empty lines between
270 # them.
271 self.RestoreIfUnset("date")
272 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE))
273
274 # TODO(machenbach): This could create a problem if the changelog contained
275 # any quotation marks.
276 text = Command("echo \"%s\" \
277 | sed -e \"s/^%s: //\" \
278 | sed -e 's/^ *//' \
279 | awk '{ \
280 if (need_space == 1) {\
281 printf(\" \");\
282 };\
283 printf(\"%%s\", $0);\
284 if ($0 ~ /^$/) {\
285 printf(\"\\n\\n\");\
286 need_space = 0;\
287 } else {\
288 need_space = 1;\
289 }\
290 }'" % (changelog_entry, self._state["date"]))
291
292 if not text:
293 self.Die("Commit message editing failed.")
294 TextToFile(text, self.Config(COMMITMSG_FILE))
295 os.remove(self.Config(CHANGELOG_ENTRY_FILE))
296
297
298 class NewBranch(Step):
299 def __init__(self):
300 Step.__init__(self, "Create a new branch from trunk.")
301
302 def RunStep(self):
303 if self.Git("checkout -b %s svn/trunk" % self.Config(TRUNKBRANCH)) is None:
304 self.Die("Checking out a new branch '%s' "
Jakob Kummerow 2013/11/06 16:37:23 nit: I'd format as: self.Die("Checking out a
Michael Achenbach 2013/11/07 15:56:46 Done.
305 "failed." % self.Config(TRUNKBRANCH))
306
307
308 class ApplyChanges(Step):
309 def __init__(self):
310 Step.__init__(self, "Apply squashed changes.")
311
312 def RunStep(self):
313 self.ApplyPatch(self.Config(PATCH_FILE))
314 Command("rm", "-f %s*" % self.Config(PATCH_FILE))
315
316
317 class SetVersion(Step):
318 def __init__(self):
319 Step.__init__(self, "Set correct version for trunk.")
320
321 def RunStep(self):
322 self.RestoreVersionIfUnset()
323 text = FileToText(self.Config(VERSION_FILE))
324 text = MSub(r"(?<=#define MAJOR_VERSION)(?P<space>\s+)\d*$",
Jakob Kummerow 2013/11/06 16:37:23 I hate this syntax. It's OK to land this as is for
Michael Achenbach 2013/11/07 15:56:46 Done.
325 r"\g<space>%s" % self._state["major"], text)
326 text = MSub(r"(?<=#define MINOR_VERSION)(?P<space>\s+)\d*$",
327 r"\g<space>%s" % self._state["minor"], text)
328 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
329 r"\g<space>%s" % self._state["build"], text)
330 text = MSub(r"(?<=#define PATCH_LEVEL)(?P<space>\s+)\d*$",
331 r"\g<space>%s" % self._state["patch"], text)
Jakob Kummerow 2013/11/06 16:37:23 It's safe to assume that patch is always 0.
Michael Achenbach 2013/11/07 15:56:46 Done.
332 text = MSub(r"(?<=#define IS_CANDIDATE_VERSION)(?P<space>\s+)\d*$",
333 r"\g<space>0", text)
334 TextToFile(text, self.Config(VERSION_FILE))
335
336
337 class CommitTrunk(Step):
338 def __init__(self):
339 Step.__init__(self, "Commit to local trunk branch.")
340
341 def RunStep(self):
342 self.Git("add \"%s\"" % self.Config(VERSION_FILE))
343 if self.Git("commit -F \"%s\"" % self.Config(COMMITMSG_FILE)) is None:
344 self.Die("'git commit' failed.")
345 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE))
Jakob Kummerow 2013/11/06 16:37:23 another command that I think should go through the
Michael Achenbach 2013/11/07 15:56:46 The whole side effects with files, their creation,
346
347
348 class SanityCheck(Step):
349 def __init__(self):
350 Step.__init__(self, "Sanity check.")
351
352 def RunStep(self):
353 if not self.Confirm("Please check if your local checkout is sane: Inspect "
354 "%s, compile, run tests. Do you want to commit this new trunk "
355 "revision to the repository?" % self.Config(VERSION_FILE)):
356 self.Die("Execution canceled.")
357
358
359 class CommitSVN(Step):
360 def __init__(self):
361 Step.__init__(self, "Commit to SVN.")
362
363 def RunStep(self):
364 result = self.Git("svn dcommit 2>&1")
365 if not result:
366 self.Die("'git svn dcommit' failed.")
367 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x),
368 result.splitlines())
369 if len(result) > 0:
370 trunk_revision = re.sub(r"^Committed r([0-9]+)", r"\1", result[0])
371
372 # Sometimes grepping for the revision fails. No idea why. If you figure
373 # out why it is flaky, please do fix it properly.
374 if not trunk_revision:
375 print("Sorry, grepping for the SVN revision failed. Please look for it "
376 "in the last command's output above and provide it manually (just "
377 "the number, without the leading \"r\").")
378 while not trunk_revision:
379 sys.stdout.write("> ")
380 trunk_revision = self.ReadLine()
381 self.Persist("trunk_revision", trunk_revision)
382
383
384 class TagRevision(Step):
385 def __init__(self):
386 Step.__init__(self, "Tag the new revision.")
387
388 def RunStep(self):
389 self.RestoreVersionIfUnset()
390 ver = "%s.%s.%s" % (self._state["major"],
391 self._state["minor"],
392 self._state["build"])
393 if self.Git("svn tag %s -m \"Tagging version %s\"" % (ver, ver)) is None:
394 self.Die("'git svn tag' failed.")
395
396
397 class CheckChromium(Step):
398 def __init__(self):
399 Step.__init__(self, "Ask for chromium checkout.")
400
401 def Run(self):
402 chrome_path = self._options.c
403 if not chrome_path:
404 print ">>> (asking for Chromium checkout)"
Jakob Kummerow 2013/11/06 16:37:23 what's this?
Michael Achenbach 2013/11/07 15:56:46 The sys.stdout.write was a way to print without li
405 sys.stdout.write("Do you have a \"NewGit\" Chromium checkout and want "
Jakob Kummerow 2013/11/06 16:37:23 This is inconsistent with the print statements els
Michael Achenbach 2013/11/07 15:56:46 Done.
406 "this script to automate creation of the roll CL? If yes, enter the "
407 "path to (and including) the \"src\" directory here, otherwise just "
408 "press <Return>: ")
409 chrome_path = self.ReadLine()
410 self.Persist("chrome_path", chrome_path)
411
412
413 class SwitchChromium(Step):
414 def __init__(self):
415 Step.__init__(self, "Switch to Chromium checkout.", requires="chrome_path")
416
417 def RunStep(self):
418 v8_path = os.getcwd()
419 self.Persist("v8_path", v8_path)
420 os.chdir(self._state["chrome_path"])
421 self.InitialEnvironmentChecks()
422 # Check for a clean workdir.
423 if self.Git("status -s -uno").strip() != "":
424 self.Die("Workspace is not clean. Please commit or undo your changes.")
425 # Assert that the DEPS file is there.
426 if not os.path.exists(self.Config(DEPS_FILE)):
427 self.Die("DEPS file not present or not writable.")
Jakob Kummerow 2013/11/06 16:37:23 nit: we only checked for existence. s/ or not writ
Michael Achenbach 2013/11/07 15:56:46 Done.
428
429
430 class UpdateChromiumCheckout(Step):
431 def __init__(self):
432 Step.__init__(self, "Update the checkout and create a new branch.",
433 requires="chrome_path")
434
435 def RunStep(self):
436 if self.Git("checkout master") is None:
437 self.Die("'git checkout master' failed.")
438 if self.Git("pull") is None:
439 self.Die("'git pull' failed, please try again.")
440
441 self.RestoreIfUnset("trunk_revision")
442 args = "checkout -b \"v8-roll-%s\"" % self._state["trunk_revision"]
Jakob Kummerow 2013/11/06 16:37:23 I don't think you need the nested quotes here. The
Michael Achenbach 2013/11/07 15:56:46 Done.
443 if self.Git(args) is None:
444 self.Die("Failed to checkout a new branch.")
445
446
447 class UploadCL(Step):
448 def __init__(self):
449 Step.__init__(self, "Create and upload CL.", requires="chrome_path")
450
451 def RunStep(self):
452 # Patch DEPS file.
453 self.RestoreIfUnset("trunk_revision")
454 deps = FileToText(self.Config(DEPS_FILE))
455 deps = re.sub("(?<=\"v8_revision\": )([0-9]+)",
456 self._state["trunk_revision"],
457 deps)
458 TextToFile(deps, self.Config(DEPS_FILE))
459
460 self.RestoreVersionIfUnset()
461 ver = "%s.%s.%s" % (self._state["major"],
462 self._state["minor"],
463 self._state["build"])
464 sys.stdout.write("Please enter the email address of a reviewer for the "
465 "roll CL: ")
466 rev = self.ReadLine()
467 args = "commit -am \"Update V8 to version %s.\n\nTBR=%s\"" % (ver, rev)
468 if self.Git(args) is None:
469 self.Die("'git commit' failed.")
470 if self.Git("cl upload --send-mail", pipe=False) is None:
471 self.Die("'git cl upload' failed, please try again.")
472 print "CL uploaded."
473
474
475 class SwitchV8(Step):
476 def __init__(self):
477 Step.__init__(self, "Returning to V8 checkout.", requires="chrome_path")
478
479 def RunStep(self):
480 self.RestoreIfUnset("v8_path")
481 os.chdir(self._state["v8_path"])
482
483
484 class CleanUp(Step):
485 def __init__(self):
486 Step.__init__(self, "Done!")
487
488 def RunStep(self):
489 self.RestoreVersionIfUnset()
490 ver = "%s.%s.%s" % (self._state["major"],
491 self._state["minor"],
492 self._state["build"])
493 self.RestoreIfUnset("trunk_revision")
494 self.RestoreIfUnset("chrome_path")
495
496 if self._state["chrome_path"]:
497 print("Congratulations, you have successfully created the trunk "
498 "revision %s and rolled it into Chromium. Please don't forget to "
499 "update the v8rel spreadsheet:" % ver)
500 else:
501 print("Congratulations, you have successfully created the trunk "
502 "revision %s. Please don't forget to roll this new version into "
503 "Chromium, and to update the v8rel spreadsheet:" % ver)
504 print "%s\ttrunk\t%s" % (ver, self._state["trunk_revision"])
505
506 self.CommonCleanup()
507 if self.Config(TRUNKBRANCH) != self._state["current_branch"]:
508 self.Git("branch -D %s" % self.Config(TRUNKBRANCH))
509
510
511 def RunScript(config,
512 options,
513 side_effects_hanlder=DEFAULT_SIDE_EFFECTS_HANDLER):
Jakob Kummerow 2013/11/06 16:37:23 s/hanlder/handler/
Michael Achenbach 2013/11/07 15:56:46 Done.
514 step_classes = [
515 Preparation,
516 FreshBranch,
517 DetectLastPush,
518 PrepareChangeLog,
519 EditChangeLog,
520 IncrementVersion,
521 CommitLocal,
522 UploadStep,
523 CommitRepository,
524 StragglerCommits,
525 SquashCommits,
526 NewBranch,
527 ApplyChanges,
528 SetVersion,
529 CommitTrunk,
530 SanityCheck,
531 CommitSVN,
532 TagRevision,
533 CheckChromium,
534 SwitchChromium,
535 UpdateChromiumCheckout,
536 UploadCL,
537 SwitchV8,
538 CleanUp,
539 ]
540
541 state = {}
542 steps = []
543 number = 0
544
545 for step_class in step_classes:
546 step = step_class()
547 step.SetNumber(number)
Jakob Kummerow 2013/11/06 16:37:23 Would it make sense to pass all these to the const
Michael Achenbach 2013/11/07 15:56:46 But then I need some argw** passing from all subco
Jakob Kummerow 2013/11/08 10:43:19 I see your point. How about a factory method then?
Michael Achenbach 2013/11/08 13:08:51 Punted.
548 step.SetConfig(config)
549 step.SetOptions(options)
550 step.SetState(state)
551 step.SetSideEffectHandler(side_effects_hanlder)
552 steps.append(step)
553 number += 1
554
555 for step in steps[options.s:]:
Jakob Kummerow 2013/11/06 16:37:23 This is remarkably easy :-)
Michael Achenbach 2013/11/07 15:56:46 Done.
556 step.Run()
557
558
559 def BuildOptions():
560 result = optparse.OptionParser()
561 result.add_option("-s",
Jakob Kummerow 2013/11/06 16:37:23 feel free to add long names while you're here: --s
Michael Achenbach 2013/11/07 15:56:46 Done.
562 help="Specify the step where to start work. Default: 0.",
563 default=0, type="int")
564 result.add_option("-l",
565 help=("Manually specify the git commit ID "
566 "of the last push to trunk."))
567 result.add_option("-c",
568 help=("Specify the path to your Chromium src/ "
569 "directory to automate the V8 roll."))
570 return result
571
572
573 def ProcessOptions(options):
574 if options.s < 0:
575 print "Bad step number %d" % options.s
576 return False
577 return True
578
579
580 def Main():
581 parser = BuildOptions()
582 (options, args) = parser.parse_args()
583 if not ProcessOptions(options):
584 parser.print_help()
585 return 1
586 RunScript(CONFIG, options)
587
588 if __name__ == "__main__":
589 sys.exit(Main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698