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

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

Issue 180873010: Refactoring: Long option names 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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): 58 class PushToTrunkOptions(CommonOptions):
59 @staticmethod 59 @staticmethod
60 def MakeForcedOptions(author, reviewer, chrome_path): 60 def MakeForcedOptions(author, reviewer, chrome_path):
61 """Convenience wrapper.""" 61 """Convenience wrapper."""
62 class Options(object): 62 class Options(object):
63 pass 63 pass
64 options = Options() 64 options = Options()
65 options.s = 0 65 options.step = 0
66 options.l = None 66 options.last_push = None
67 options.b = None 67 options.last_bleeding_edge = None
68 options.f = True 68 options.force = True
69 options.m = False 69 options.manual = False
70 options.c = chrome_path 70 options.chromium = chrome_path
71 options.reviewer = reviewer 71 options.reviewer = reviewer
72 options.a = author 72 options.author = author
73 return PushToTrunkOptions(options) 73 return PushToTrunkOptions(options)
74 74
75 def __init__(self, options): 75 def __init__(self, options):
76 super(PushToTrunkOptions, self).__init__(options, options.m) 76 super(PushToTrunkOptions, self).__init__(options, options.manual)
77 self.requires_editor = not options.f 77 self.requires_editor = not options.force
78 self.wait_for_lgtm = not options.f 78 self.wait_for_lgtm = not options.force
79 self.tbr_commit = not options.m 79 self.tbr_commit = not options.manual
80 self.l = options.l 80 self.last_push = options.last_push
81 self.reviewer = options.reviewer 81 self.reviewer = options.reviewer
82 self.c = options.c 82 self.chromium = options.chromium
83 self.b = getattr(options, 'b', None) 83 self.last_bleeding_edge = getattr(options, 'last_bleeding_edge', None)
84 self.author = getattr(options, 'a', None) 84 self.author = getattr(options, 'author', None)
85 85
86 86
87 class Preparation(Step): 87 class Preparation(Step):
88 MESSAGE = "Preparation." 88 MESSAGE = "Preparation."
89 89
90 def RunStep(self): 90 def RunStep(self):
91 self.InitialEnvironmentChecks() 91 self.InitialEnvironmentChecks()
92 self.CommonPrepare() 92 self.CommonPrepare()
93 self.PrepareBranch() 93 self.PrepareBranch()
94 self.DeleteBranch(self.Config(TRUNKBRANCH)) 94 self.DeleteBranch(self.Config(TRUNKBRANCH))
95 95
96 96
97 class FreshBranch(Step): 97 class FreshBranch(Step):
98 MESSAGE = "Create a fresh branch." 98 MESSAGE = "Create a fresh branch."
99 99
100 def RunStep(self): 100 def RunStep(self):
101 self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") 101 self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge")
102 102
103 103
104 class DetectLastPush(Step): 104 class DetectLastPush(Step):
105 MESSAGE = "Detect commit ID of last push to trunk." 105 MESSAGE = "Detect commit ID of last push to trunk."
106 106
107 def RunStep(self): 107 def RunStep(self):
108 last_push = self._options.l or self.FindLastTrunkPush() 108 last_push = self._options.last_push or self.FindLastTrunkPush()
109 while True: 109 while True:
110 # Print assumed commit, circumventing git's pager. 110 # Print assumed commit, circumventing git's pager.
111 print self.GitLog(n=1, git_hash=last_push) 111 print self.GitLog(n=1, git_hash=last_push)
112 if self.Confirm("Is the commit printed above the last push to trunk?"): 112 if self.Confirm("Is the commit printed above the last push to trunk?"):
113 break 113 break
114 last_push = self.FindLastTrunkPush(parent_hash=last_push) 114 last_push = self.FindLastTrunkPush(parent_hash=last_push)
115 115
116 if self._options.b: 116 if self._options.last_bleeding_edge:
117 # Read the bleeding edge revision of the last push from a command-line 117 # Read the bleeding edge revision of the last push from a command-line
118 # option. 118 # option.
119 last_push_bleeding_edge = self._options.b 119 last_push_bleeding_edge = self._options.last_bleeding_edge
120 else: 120 else:
121 # Retrieve the bleeding edge revision of the last push from the text in 121 # Retrieve the bleeding edge revision of the last push from the text in
122 # the push commit message. 122 # the push commit message.
123 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push) 123 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
124 last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1) 124 last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1)
125 if not last_push_be_svn: 125 if not last_push_be_svn:
126 self.Die("Could not retrieve bleeding edge revision for trunk push %s" 126 self.Die("Could not retrieve bleeding edge revision for trunk push %s"
127 % last_push) 127 % last_push)
128 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn) 128 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn)
129 if not last_push_bleeding_edge: 129 if not last_push_bleeding_edge:
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 MESSAGE = "Tag the new revision." 408 MESSAGE = "Tag the new revision."
409 409
410 def RunStep(self): 410 def RunStep(self):
411 self.GitSVNTag(self["version"]) 411 self.GitSVNTag(self["version"])
412 412
413 413
414 class CheckChromium(Step): 414 class CheckChromium(Step):
415 MESSAGE = "Ask for chromium checkout." 415 MESSAGE = "Ask for chromium checkout."
416 416
417 def Run(self): 417 def Run(self):
418 self["chrome_path"] = self._options.c 418 self["chrome_path"] = self._options.chromium
419 if not self["chrome_path"]: 419 if not self["chrome_path"]:
420 self.DieNoManualMode("Please specify the path to a Chromium checkout in " 420 self.DieNoManualMode("Please specify the path to a Chromium checkout in "
421 "forced mode.") 421 "forced mode.")
422 print ("Do you have a \"NewGit\" Chromium checkout and want " 422 print ("Do you have a \"NewGit\" Chromium checkout and want "
423 "this script to automate creation of the roll CL? If yes, enter the " 423 "this script to automate creation of the roll CL? If yes, enter the "
424 "path to (and including) the \"src\" directory here, otherwise just " 424 "path to (and including) the \"src\" directory here, otherwise just "
425 "press <Return>: "), 425 "press <Return>: "),
426 self["chrome_path"] = self.ReadLine() 426 self["chrome_path"] = self.ReadLine()
427 427
428 428
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 SwitchV8, 540 SwitchV8,
541 CleanUp, 541 CleanUp,
542 ] 542 ]
543 543
544 RunScript(step_classes, config, options, side_effect_handler) 544 RunScript(step_classes, config, options, side_effect_handler)
545 545
546 546
547 def BuildOptions(): 547 def BuildOptions():
548 parser = argparse.ArgumentParser() 548 parser = argparse.ArgumentParser()
549 group = parser.add_mutually_exclusive_group() 549 group = parser.add_mutually_exclusive_group()
550 group.add_argument("-f", "--force", dest="f", 550 group.add_argument("-f", "--force",
551 help="Don't prompt the user.", 551 help="Don't prompt the user.",
552 default=False, action="store_true") 552 default=False, action="store_true")
553 group.add_argument("-m", "--manual", dest="m", 553 group.add_argument("-m", "--manual",
554 help="Prompt the user at every important step.", 554 help="Prompt the user at every important step.",
555 default=False, action="store_true") 555 default=False, action="store_true")
556 parser.add_argument("-a", "--author", dest="a", 556 parser.add_argument("-a", "--author",
557 help="The author email used for rietveld.") 557 help="The author email used for rietveld.")
558 parser.add_argument("-b", "--last-bleeding-edge", dest="b", 558 parser.add_argument("-b", "--last-bleeding-edge",
559 help=("The git commit ID of the last bleeding edge " 559 help=("The git commit ID of the last bleeding edge "
560 "revision that was pushed to trunk. This is used " 560 "revision that was pushed to trunk. This is used "
561 "for the auto-generated ChangeLog entry.")) 561 "for the auto-generated ChangeLog entry."))
562 parser.add_argument("-c", "--chromium", dest="c", 562 parser.add_argument("-c", "--chromium",
563 help=("The path to your Chromium src/ directory to " 563 help=("The path to your Chromium src/ directory to "
564 "automate the V8 roll.")) 564 "automate the V8 roll."))
565 parser.add_argument("-l", "--last-push", dest="l", 565 parser.add_argument("-l", "--last-push",
566 help="The git commit ID of the last push to trunk.") 566 help="The git commit ID of the last push to trunk.")
567 parser.add_argument("-r", "--reviewer", 567 parser.add_argument("-r", "--reviewer",
568 help="The account name to be used for reviews.") 568 help="The account name to be used for reviews.")
569 parser.add_argument("-s", "--step", dest="s", 569 parser.add_argument("-s", "--step",
570 help="The step where to start work. Default: 0.", 570 help="The step where to start work. Default: 0.",
571 default=0, type=int) 571 default=0, type=int)
572 return parser 572 return parser
573 573
574 574
575 def ProcessOptions(options): 575 def ProcessOptions(options):
576 if options.s < 0: 576 if options.step < 0:
577 print "Bad step number %d" % options.s 577 print "Bad step number %d" % options.step
578 return False 578 return False
579 if not options.m and not options.reviewer: 579 if not options.manual and not options.reviewer:
580 print "A reviewer (-r) is required in (semi-)automatic mode." 580 print "A reviewer (-r) is required in (semi-)automatic mode."
581 return False 581 return False
582 if not options.m and not options.c: 582 if not options.manual and not options.chromium:
583 print "A chromium checkout (-c) is required in (semi-)automatic mode." 583 print "A chromium checkout (-c) is required in (semi-)automatic mode."
584 return False 584 return False
585 if not options.m and not options.a: 585 if not options.manual and not options.author:
586 print "Specify your chromium.org email with -a in (semi-)automatic mode." 586 print "Specify your chromium.org email with -a in (semi-)automatic mode."
587 return False 587 return False
588 return True 588 return True
589 589
590 590
591 def Main(): 591 def Main():
592 parser = BuildOptions() 592 parser = BuildOptions()
593 options = parser.parse_args() 593 options = parser.parse_args()
594 if not ProcessOptions(options): 594 if not ProcessOptions(options):
595 parser.print_help() 595 parser.print_help()
596 return 1 596 return 1
597 RunPushToTrunk(CONFIG, PushToTrunkOptions(options)) 597 RunPushToTrunk(CONFIG, PushToTrunkOptions(options))
598 598
599 if __name__ == "__main__": 599 if __name__ == "__main__":
600 sys.exit(Main()) 600 sys.exit(Main())
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