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

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

Issue 185263003: Refactoring: Make script dependencies more object-oriented in push and merge scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months 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
« no previous file with comments | « tools/push-to-trunk/merge_to_branch.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", 48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry",
49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", 49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file",
50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", 50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg",
51 DEPS_FILE: "DEPS", 51 DEPS_FILE: "DEPS",
52 } 52 }
53 53
54 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" 54 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)"
55 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") 55 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
56 56
57 57
58 class PushToTrunkOptions(CommonOptions):
59 @staticmethod
60 def MakeForcedOptions(author, reviewer, chrome_path):
61 """Convenience wrapper."""
62 class Options(object):
63 pass
64 options = Options()
65 options.step = 0
66 options.last_push = None
67 options.last_bleeding_edge = None
68 options.force = True
69 options.manual = False
70 options.chromium = chrome_path
71 options.reviewer = reviewer
72 options.author = author
73 return PushToTrunkOptions(options)
74
75 def __init__(self, options):
76 super(PushToTrunkOptions, self).__init__(options, options.manual)
77 self.requires_editor = not options.force
78 self.wait_for_lgtm = not options.force
79 self.tbr_commit = not options.manual
80 self.last_push = options.last_push
81 self.reviewer = options.reviewer
82 self.chromium = options.chromium
83 self.last_bleeding_edge = getattr(options, 'last_bleeding_edge', None)
84 self.author = getattr(options, 'author', None)
85
86
87 class Preparation(Step): 58 class Preparation(Step):
88 MESSAGE = "Preparation." 59 MESSAGE = "Preparation."
89 60
90 def RunStep(self): 61 def RunStep(self):
91 self.InitialEnvironmentChecks() 62 self.InitialEnvironmentChecks()
92 self.CommonPrepare() 63 self.CommonPrepare()
93 self.PrepareBranch() 64 self.PrepareBranch()
94 self.DeleteBranch(self.Config(TRUNKBRANCH)) 65 self.DeleteBranch(self.Config(TRUNKBRANCH))
95 66
96 67
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 "Chromium, and to update the v8rel spreadsheet:" 475 "Chromium, and to update the v8rel spreadsheet:"
505 % self["version"]) 476 % self["version"])
506 print "%s\ttrunk\t%s" % (self["version"], 477 print "%s\ttrunk\t%s" % (self["version"],
507 self["trunk_revision"]) 478 self["trunk_revision"])
508 479
509 self.CommonCleanup() 480 self.CommonCleanup()
510 if self.Config(TRUNKBRANCH) != self["current_branch"]: 481 if self.Config(TRUNKBRANCH) != self["current_branch"]:
511 self.GitDeleteBranch(self.Config(TRUNKBRANCH)) 482 self.GitDeleteBranch(self.Config(TRUNKBRANCH))
512 483
513 484
514 def RunPushToTrunk(config, 485 class PushToTrunk(ScriptsBase):
515 options, 486 def _PrepareOptions(self, parser):
516 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): 487 group = parser.add_mutually_exclusive_group()
517 step_classes = [ 488 group.add_argument("-f", "--force",
518 Preparation, 489 help="Don't prompt the user.",
519 FreshBranch, 490 default=False, action="store_true")
520 DetectLastPush, 491 group.add_argument("-m", "--manual",
521 PrepareChangeLog, 492 help="Prompt the user at every important step.",
522 EditChangeLog, 493 default=False, action="store_true")
523 IncrementVersion, 494 parser.add_argument("-b", "--last-bleeding-edge",
524 CommitLocal, 495 help=("The git commit ID of the last bleeding edge "
525 UploadStep, 496 "revision that was pushed to trunk. This is "
526 CommitRepository, 497 "used for the auto-generated ChangeLog entry."))
527 StragglerCommits, 498 parser.add_argument("-c", "--chromium",
528 SquashCommits, 499 help=("The path to your Chromium src/ "
529 NewBranch, 500 "directory to automate the V8 roll."))
530 ApplyChanges, 501 parser.add_argument("-l", "--last-push",
531 SetVersion, 502 help="The git commit ID of the last push to trunk.")
532 CommitTrunk,
533 SanityCheck,
534 CommitSVN,
535 TagRevision,
536 CheckChromium,
537 SwitchChromium,
538 UpdateChromiumCheckout,
539 UploadCL,
540 SwitchV8,
541 CleanUp,
542 ]
543 503
544 RunScript(step_classes, config, options, side_effect_handler) 504 def _ProcessOptions(self, options):
505 if not options.manual and not options.reviewer:
506 print "A reviewer (-r) is required in (semi-)automatic mode."
507 return False
508 if not options.manual and not options.chromium:
509 print "A chromium checkout (-c) is required in (semi-)automatic mode."
510 return False
511 if not options.manual and not options.author:
512 print "Specify your chromium.org email with -a in (semi-)automatic mode."
513 return False
514
515 options.tbr_commit = not options.manual
516 return True
517
518 def _Steps(self):
519 return [
520 Preparation,
521 FreshBranch,
522 DetectLastPush,
523 PrepareChangeLog,
524 EditChangeLog,
525 IncrementVersion,
526 CommitLocal,
527 UploadStep,
528 CommitRepository,
529 StragglerCommits,
530 SquashCommits,
531 NewBranch,
532 ApplyChanges,
533 SetVersion,
534 CommitTrunk,
535 SanityCheck,
536 CommitSVN,
537 TagRevision,
538 CheckChromium,
539 SwitchChromium,
540 UpdateChromiumCheckout,
541 UploadCL,
542 SwitchV8,
543 CleanUp,
544 ]
545 545
546 546
547 def BuildOptions():
548 parser = argparse.ArgumentParser()
549 group = parser.add_mutually_exclusive_group()
550 group.add_argument("-f", "--force",
551 help="Don't prompt the user.",
552 default=False, action="store_true")
553 group.add_argument("-m", "--manual",
554 help="Prompt the user at every important step.",
555 default=False, action="store_true")
556 parser.add_argument("-a", "--author",
557 help="The author email used for rietveld.")
558 parser.add_argument("-b", "--last-bleeding-edge",
559 help=("The git commit ID of the last bleeding edge "
560 "revision that was pushed to trunk. This is used "
561 "for the auto-generated ChangeLog entry."))
562 parser.add_argument("-c", "--chromium",
563 help=("The path to your Chromium src/ directory to "
564 "automate the V8 roll."))
565 parser.add_argument("-l", "--last-push",
566 help="The git commit ID of the last push to trunk.")
567 parser.add_argument("-r", "--reviewer",
568 help="The account name to be used for reviews.")
569 parser.add_argument("-s", "--step",
570 help="The step where to start work. Default: 0.",
571 default=0, type=int)
572 return parser
573
574
575 def ProcessOptions(options):
576 if options.step < 0:
577 print "Bad step number %d" % options.step
578 return False
579 if not options.manual and not options.reviewer:
580 print "A reviewer (-r) is required in (semi-)automatic mode."
581 return False
582 if not options.manual and not options.chromium:
583 print "A chromium checkout (-c) is required in (semi-)automatic mode."
584 return False
585 if not options.manual and not options.author:
586 print "Specify your chromium.org email with -a in (semi-)automatic mode."
587 return False
588 return True
589
590
591 def Main():
592 parser = BuildOptions()
593 options = parser.parse_args()
594 if not ProcessOptions(options):
595 parser.print_help()
596 return 1
597 RunPushToTrunk(CONFIG, PushToTrunkOptions(options))
598
599 if __name__ == "__main__": 547 if __name__ == "__main__":
600 sys.exit(Main()) 548 sys.exit(PushToTrunk(CONFIG).Run())
OLDNEW
« no previous file with comments | « tools/push-to-trunk/merge_to_branch.py ('k') | tools/push-to-trunk/test_scripts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698