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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 @staticmethod | 56 @staticmethod |
57 def MakeForcedOptions(author, reviewer, chrome_path): | 57 def MakeForcedOptions(author, reviewer, chrome_path): |
58 """Convenience wrapper.""" | 58 """Convenience wrapper.""" |
59 class Options(object): | 59 class Options(object): |
60 pass | 60 pass |
61 options = Options() | 61 options = Options() |
62 options.s = 0 | 62 options.s = 0 |
63 options.l = None | 63 options.l = None |
64 options.f = True | 64 options.f = True |
65 options.m = False | 65 options.m = False |
66 options.r = reviewer | |
67 options.c = chrome_path | 66 options.c = chrome_path |
68 options.a = author | 67 options.a = author |
69 return PushToTrunkOptions(options) | 68 return PushToTrunkOptions(options) |
70 | 69 |
71 def __init__(self, options): | 70 def __init__(self, options): |
72 super(PushToTrunkOptions, self).__init__(options, options.m) | 71 super(PushToTrunkOptions, self).__init__(options, options.m) |
73 self.requires_editor = not options.f | 72 self.requires_editor = not options.f |
74 self.wait_for_lgtm = not options.f | 73 self.wait_for_lgtm = not options.f |
75 self.tbr_commit = not options.m | 74 self.tbr_commit = not options.m |
76 self.l = options.l | 75 self.l = options.l |
77 self.r = options.r | 76 self.reviewer = options.reviewer |
78 self.c = options.c | 77 self.c = options.c |
79 self.author = getattr(options, 'a', None) | 78 self.author = getattr(options, 'a', None) |
80 | 79 |
81 class Preparation(Step): | 80 class Preparation(Step): |
82 MESSAGE = "Preparation." | 81 MESSAGE = "Preparation." |
83 | 82 |
84 def RunStep(self): | 83 def RunStep(self): |
85 self.InitialEnvironmentChecks() | 84 self.InitialEnvironmentChecks() |
86 self.CommonPrepare() | 85 self.CommonPrepare() |
87 self.PrepareBranch() | 86 self.PrepareBranch() |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 def RunStep(self): | 232 def RunStep(self): |
234 self.RestoreVersionIfUnset("new_") | 233 self.RestoreVersionIfUnset("new_") |
235 prep_commit_msg = ("Prepare push to trunk. " | 234 prep_commit_msg = ("Prepare push to trunk. " |
236 "Now working on version %s.%s.%s." % (self._state["new_major"], | 235 "Now working on version %s.%s.%s." % (self._state["new_major"], |
237 self._state["new_minor"], | 236 self._state["new_minor"], |
238 self._state["new_build"])) | 237 self._state["new_build"])) |
239 self.Persist("prep_commit_msg", prep_commit_msg) | 238 self.Persist("prep_commit_msg", prep_commit_msg) |
240 | 239 |
241 # Include optional TBR only in the git command. The persisted commit | 240 # Include optional TBR only in the git command. The persisted commit |
242 # message is used for finding the commit again later. | 241 # message is used for finding the commit again later. |
243 review = "\n\nTBR=%s" % self._options.r if self._options.tbr_commit else "" | 242 if self._options.tbr_commit: |
| 243 review = "\n\nTBR=%s" % self._options.reviewer |
| 244 else: |
| 245 review = "" |
244 if self.Git("commit -a -m \"%s%s\"" % (prep_commit_msg, review)) is None: | 246 if self.Git("commit -a -m \"%s%s\"" % (prep_commit_msg, review)) is None: |
245 self.Die("'git commit -a' failed.") | 247 self.Die("'git commit -a' failed.") |
246 | 248 |
247 | 249 |
248 class CommitRepository(Step): | 250 class CommitRepository(Step): |
249 MESSAGE = "Commit to the repository." | 251 MESSAGE = "Commit to the repository." |
250 | 252 |
251 def RunStep(self): | 253 def RunStep(self): |
252 self.WaitForLGTM() | 254 self.WaitForLGTM() |
253 # Re-read the ChangeLog entry (to pick up possible changes). | 255 # Re-read the ChangeLog entry (to pick up possible changes). |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 deps = FileToText(self.Config(DEPS_FILE)) | 476 deps = FileToText(self.Config(DEPS_FILE)) |
475 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", | 477 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", |
476 self._state["trunk_revision"], | 478 self._state["trunk_revision"], |
477 deps) | 479 deps) |
478 TextToFile(deps, self.Config(DEPS_FILE)) | 480 TextToFile(deps, self.Config(DEPS_FILE)) |
479 | 481 |
480 self.RestoreVersionIfUnset() | 482 self.RestoreVersionIfUnset() |
481 ver = "%s.%s.%s" % (self._state["major"], | 483 ver = "%s.%s.%s" % (self._state["major"], |
482 self._state["minor"], | 484 self._state["minor"], |
483 self._state["build"]) | 485 self._state["build"]) |
484 if self._options.r: | 486 if self._options.reviewer: |
485 print "Using account %s for review." % self._options.r | 487 print "Using account %s for review." % self._options.reviewer |
486 rev = self._options.r | 488 rev = self._options.reviewer |
487 else: | 489 else: |
488 print "Please enter the email address of a reviewer for the roll CL: ", | 490 print "Please enter the email address of a reviewer for the roll CL: ", |
489 self.DieNoManualMode("A reviewer must be specified in forced mode.") | 491 self.DieNoManualMode("A reviewer must be specified in forced mode.") |
490 rev = self.ReadLine() | 492 rev = self.ReadLine() |
491 self.RestoreIfUnset("svn_revision") | 493 self.RestoreIfUnset("svn_revision") |
492 args = ("commit -am \"Update V8 to version %s " | 494 args = ("commit -am \"Update V8 to version %s " |
493 "(based on bleeding_edge revision r%s).\n\nTBR=%s\"" | 495 "(based on bleeding_edge revision r%s).\n\nTBR=%s\"" |
494 % (ver, self._state["svn_revision"], rev)) | 496 % (ver, self._state["svn_revision"], rev)) |
495 if self.Git(args) is None: | 497 if self.Git(args) is None: |
496 self.Die("'git commit' failed.") | 498 self.Die("'git commit' failed.") |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 "directory to automate the V8 roll.")) | 582 "directory to automate the V8 roll.")) |
581 result.add_option("-f", "--force", dest="f", | 583 result.add_option("-f", "--force", dest="f", |
582 help="Don't prompt the user.", | 584 help="Don't prompt the user.", |
583 default=False, action="store_true") | 585 default=False, action="store_true") |
584 result.add_option("-l", "--last-push", dest="l", | 586 result.add_option("-l", "--last-push", dest="l", |
585 help=("Manually specify the git commit ID " | 587 help=("Manually specify the git commit ID " |
586 "of the last push to trunk.")) | 588 "of the last push to trunk.")) |
587 result.add_option("-m", "--manual", dest="m", | 589 result.add_option("-m", "--manual", dest="m", |
588 help="Prompt the user at every important step.", | 590 help="Prompt the user at every important step.", |
589 default=False, action="store_true") | 591 default=False, action="store_true") |
590 result.add_option("-r", "--reviewer", dest="r", | 592 result.add_option("-r", "--reviewer", |
591 help=("Specify the account name to be used for reviews.")) | 593 help=("Specify the account name to be used for reviews.")) |
592 result.add_option("-s", "--step", dest="s", | 594 result.add_option("-s", "--step", dest="s", |
593 help="Specify the step where to start work. Default: 0.", | 595 help="Specify the step where to start work. Default: 0.", |
594 default=0, type="int") | 596 default=0, type="int") |
595 return result | 597 return result |
596 | 598 |
597 | 599 |
598 def ProcessOptions(options): | 600 def ProcessOptions(options): |
599 if options.s < 0: | 601 if options.s < 0: |
600 print "Bad step number %d" % options.s | 602 print "Bad step number %d" % options.s |
601 return False | 603 return False |
602 if not options.m and not options.r: | 604 if not options.m and not options.reviewer: |
603 print "A reviewer (-r) is required in (semi-)automatic mode." | 605 print "A reviewer (-r) is required in (semi-)automatic mode." |
604 return False | 606 return False |
605 if options.f and options.m: | 607 if options.f and options.m: |
606 print "Manual and forced mode cannot be combined." | 608 print "Manual and forced mode cannot be combined." |
607 return False | 609 return False |
608 if not options.m and not options.c: | 610 if not options.m and not options.c: |
609 print "A chromium checkout (-c) is required in (semi-)automatic mode." | 611 print "A chromium checkout (-c) is required in (semi-)automatic mode." |
610 return False | 612 return False |
611 if not options.m and not options.a: | 613 if not options.m and not options.a: |
612 print "Specify your chromium.org email with -a in (semi-)automatic mode." | 614 print "Specify your chromium.org email with -a in (semi-)automatic mode." |
613 return False | 615 return False |
614 return True | 616 return True |
615 | 617 |
616 | 618 |
617 def Main(): | 619 def Main(): |
618 parser = BuildOptions() | 620 parser = BuildOptions() |
619 (options, args) = parser.parse_args() | 621 (options, args) = parser.parse_args() |
620 if not ProcessOptions(options): | 622 if not ProcessOptions(options): |
621 parser.print_help() | 623 parser.print_help() |
622 return 1 | 624 return 1 |
623 RunPushToTrunk(CONFIG, PushToTrunkOptions(options)) | 625 RunPushToTrunk(CONFIG, PushToTrunkOptions(options)) |
624 | 626 |
625 if __name__ == "__main__": | 627 if __name__ == "__main__": |
626 sys.exit(Main()) | 628 sys.exit(Main()) |
OLD | NEW |