Chromium Code Reviews| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 128 |
| 129 | 129 |
| 130 class EditChangeLog(Step): | 130 class EditChangeLog(Step): |
| 131 def __init__(self): | 131 def __init__(self): |
| 132 Step.__init__(self, "Edit ChangeLog entry.") | 132 Step.__init__(self, "Edit ChangeLog entry.") |
| 133 | 133 |
| 134 def RunStep(self): | 134 def RunStep(self): |
| 135 print ("Please press <Return> to have your EDITOR open the ChangeLog " | 135 print ("Please press <Return> to have your EDITOR open the ChangeLog " |
| 136 "entry, then edit its contents to your liking. When you're done, " | 136 "entry, then edit its contents to your liking. When you're done, " |
| 137 "save the file and exit your EDITOR. ") | 137 "save the file and exit your EDITOR. ") |
| 138 self.ReadLine() | 138 self.ReadLine(default="") |
| 139 | 139 |
| 140 # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is | |
| 141 # well tested. | |
| 140 self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) | 142 self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) |
| 141 handle, new_changelog = tempfile.mkstemp() | 143 handle, new_changelog = tempfile.mkstemp() |
| 142 os.close(handle) | 144 os.close(handle) |
| 143 | 145 |
| 144 # (1) Eliminate tabs, (2) fix too little and (3) too much indentation, and | 146 # (1) Eliminate tabs, (2) fix too little and (3) too much indentation, and |
| 145 # (4) eliminate trailing whitespace. | 147 # (4) eliminate trailing whitespace. |
| 146 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() | 148 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() |
| 147 changelog_entry = MSub(r"\t", r" ", changelog_entry) | 149 changelog_entry = MSub(r"\t", r" ", changelog_entry) |
| 148 changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1", changelog_entry) | 150 changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1", changelog_entry) |
| 149 changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1", changelog_entry) | 151 changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1", changelog_entry) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 result.splitlines()) | 349 result.splitlines()) |
| 348 if len(result) > 0: | 350 if len(result) > 0: |
| 349 trunk_revision = re.sub(r"^Committed r([0-9]+)", r"\1", result[0]) | 351 trunk_revision = re.sub(r"^Committed r([0-9]+)", r"\1", result[0]) |
| 350 | 352 |
| 351 # Sometimes grepping for the revision fails. No idea why. If you figure | 353 # Sometimes grepping for the revision fails. No idea why. If you figure |
| 352 # out why it is flaky, please do fix it properly. | 354 # out why it is flaky, please do fix it properly. |
| 353 if not trunk_revision: | 355 if not trunk_revision: |
| 354 print("Sorry, grepping for the SVN revision failed. Please look for it " | 356 print("Sorry, grepping for the SVN revision failed. Please look for it " |
| 355 "in the last command's output above and provide it manually (just " | 357 "in the last command's output above and provide it manually (just " |
| 356 "the number, without the leading \"r\").") | 358 "the number, without the leading \"r\").") |
| 359 self.DieInForcedMode("Can't prompt in forced mode.") | |
| 357 while not trunk_revision: | 360 while not trunk_revision: |
| 358 print "> ", | 361 print "> ", |
| 359 trunk_revision = self.ReadLine() | 362 trunk_revision = self.ReadLine() |
| 360 self.Persist("trunk_revision", trunk_revision) | 363 self.Persist("trunk_revision", trunk_revision) |
| 361 | 364 |
| 362 | 365 |
| 363 class TagRevision(Step): | 366 class TagRevision(Step): |
| 364 def __init__(self): | 367 def __init__(self): |
| 365 Step.__init__(self, "Tag the new revision.") | 368 Step.__init__(self, "Tag the new revision.") |
| 366 | 369 |
| 367 def RunStep(self): | 370 def RunStep(self): |
| 368 self.RestoreVersionIfUnset() | 371 self.RestoreVersionIfUnset() |
| 369 ver = "%s.%s.%s" % (self._state["major"], | 372 ver = "%s.%s.%s" % (self._state["major"], |
| 370 self._state["minor"], | 373 self._state["minor"], |
| 371 self._state["build"]) | 374 self._state["build"]) |
| 372 if self.Git("svn tag %s -m \"Tagging version %s\"" % (ver, ver)) is None: | 375 if self.Git("svn tag %s -m \"Tagging version %s\"" % (ver, ver)) is None: |
| 373 self.Die("'git svn tag' failed.") | 376 self.Die("'git svn tag' failed.") |
| 374 | 377 |
| 375 | 378 |
| 376 class CheckChromium(Step): | 379 class CheckChromium(Step): |
| 377 def __init__(self): | 380 def __init__(self): |
| 378 Step.__init__(self, "Ask for chromium checkout.") | 381 Step.__init__(self, "Ask for chromium checkout.") |
| 379 | 382 |
| 380 def Run(self): | 383 def Run(self): |
| 381 chrome_path = self._options.c | 384 chrome_path = self._options.c |
| 382 if not chrome_path: | 385 if not chrome_path: |
| 386 self.DieInForcedMode("Please specify the path to a Chromium checkout in " | |
| 387 "forced mode.") | |
| 383 print ("Do you have a \"NewGit\" Chromium checkout and want " | 388 print ("Do you have a \"NewGit\" Chromium checkout and want " |
| 384 "this script to automate creation of the roll CL? If yes, enter the " | 389 "this script to automate creation of the roll CL? If yes, enter the " |
| 385 "path to (and including) the \"src\" directory here, otherwise just " | 390 "path to (and including) the \"src\" directory here, otherwise just " |
| 386 "press <Return>: "), | 391 "press <Return>: "), |
| 387 chrome_path = self.ReadLine() | 392 chrome_path = self.ReadLine() |
| 388 self.Persist("chrome_path", chrome_path) | 393 self.Persist("chrome_path", chrome_path) |
| 389 | 394 |
| 390 | 395 |
| 391 class SwitchChromium(Step): | 396 class SwitchChromium(Step): |
| 392 def __init__(self): | 397 def __init__(self): |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 deps = FileToText(self.Config(DEPS_FILE)) | 440 deps = FileToText(self.Config(DEPS_FILE)) |
| 436 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", | 441 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", |
| 437 self._state["trunk_revision"], | 442 self._state["trunk_revision"], |
| 438 deps) | 443 deps) |
| 439 TextToFile(deps, self.Config(DEPS_FILE)) | 444 TextToFile(deps, self.Config(DEPS_FILE)) |
| 440 | 445 |
| 441 self.RestoreVersionIfUnset() | 446 self.RestoreVersionIfUnset() |
| 442 ver = "%s.%s.%s" % (self._state["major"], | 447 ver = "%s.%s.%s" % (self._state["major"], |
| 443 self._state["minor"], | 448 self._state["minor"], |
| 444 self._state["build"]) | 449 self._state["build"]) |
| 445 print "Please enter the email address of a reviewer for the roll CL: ", | 450 if self._options and self._options.r: |
| 446 rev = self.ReadLine() | 451 print "Using account %s for review." % self._options.r |
| 452 rev = self._options.r | |
| 453 else: | |
| 454 print "Please enter the email address of a reviewer for the roll CL: ", | |
| 455 self.DieInForcedMode("A reviewer must be specified in forced mode.") | |
| 456 rev = self.ReadLine() | |
| 447 args = "commit -am \"Update V8 to version %s.\n\nTBR=%s\"" % (ver, rev) | 457 args = "commit -am \"Update V8 to version %s.\n\nTBR=%s\"" % (ver, rev) |
| 448 if self.Git(args) is None: | 458 if self.Git(args) is None: |
| 449 self.Die("'git commit' failed.") | 459 self.Die("'git commit' failed.") |
| 450 if self.Git("cl upload --send-mail", pipe=False) is None: | 460 if self.Git("cl upload --send-mail", pipe=False) is None: |
| 451 self.Die("'git cl upload' failed, please try again.") | 461 self.Die("'git cl upload' failed, please try again.") |
| 452 print "CL uploaded." | 462 print "CL uploaded." |
| 453 | 463 |
| 454 | 464 |
| 455 class SwitchV8(Step): | 465 class SwitchV8(Step): |
| 456 def __init__(self): | 466 def __init__(self): |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 UploadCL, | 526 UploadCL, |
| 517 SwitchV8, | 527 SwitchV8, |
| 518 CleanUp, | 528 CleanUp, |
| 519 ] | 529 ] |
| 520 | 530 |
| 521 RunScript(step_classes, config, options, side_effect_handler) | 531 RunScript(step_classes, config, options, side_effect_handler) |
| 522 | 532 |
| 523 | 533 |
| 524 def BuildOptions(): | 534 def BuildOptions(): |
| 525 result = optparse.OptionParser() | 535 result = optparse.OptionParser() |
| 536 result.add_option("-c", "--chromium", dest="c", | |
| 537 help=("Specify the path to your Chromium src/ " | |
| 538 "directory to automate the V8 roll.")) | |
| 539 result.add_option("-f", "--force", dest="f", | |
| 540 help="Don't prompt to the user.", | |
|
Jakob Kummerow
2013/11/19 16:25:33
nit: s/to //
| |
| 541 default=False, action="store_true") | |
| 542 result.add_option("-l", "--last-push", dest="l", | |
| 543 help=("Manually specify the git commit ID " | |
| 544 "of the last push to trunk.")) | |
| 545 result.add_option("-r", "--reviewer", dest="r", | |
| 546 help=("Specify the account name to be used for reviews.")) | |
| 526 result.add_option("-s", "--step", dest="s", | 547 result.add_option("-s", "--step", dest="s", |
| 527 help="Specify the step where to start work. Default: 0.", | 548 help="Specify the step where to start work. Default: 0.", |
| 528 default=0, type="int") | 549 default=0, type="int") |
| 529 result.add_option("-l", "--last-push", dest="l", | |
| 530 help=("Manually specify the git commit ID " | |
| 531 "of the last push to trunk.")) | |
| 532 result.add_option("-c", "--chromium", dest="c", | |
| 533 help=("Specify the path to your Chromium src/ " | |
| 534 "directory to automate the V8 roll.")) | |
| 535 return result | 550 return result |
| 536 | 551 |
| 537 | 552 |
| 538 def ProcessOptions(options): | 553 def ProcessOptions(options): |
| 539 if options.s < 0: | 554 if options.s < 0: |
| 540 print "Bad step number %d" % options.s | 555 print "Bad step number %d" % options.s |
| 541 return False | 556 return False |
| 542 return True | 557 return True |
| 543 | 558 |
| 544 | 559 |
| 545 def Main(): | 560 def Main(): |
| 546 parser = BuildOptions() | 561 parser = BuildOptions() |
| 547 (options, args) = parser.parse_args() | 562 (options, args) = parser.parse_args() |
| 548 if not ProcessOptions(options): | 563 if not ProcessOptions(options): |
| 549 parser.print_help() | 564 parser.print_help() |
| 550 return 1 | 565 return 1 |
| 551 RunScript(CONFIG, options) | 566 RunScript(CONFIG, options) |
| 552 | 567 |
| 553 if __name__ == "__main__": | 568 if __name__ == "__main__": |
| 554 sys.exit(Main()) | 569 sys.exit(Main()) |
| OLD | NEW |