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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/push-to-trunk/push_to_trunk.py
diff --git a/tools/push-to-trunk/push_to_trunk.py b/tools/push-to-trunk/push_to_trunk.py
index d227a50bede6b05af191ddb65cbd61ecb720613a..111578aef59167a5f8e403f005f17a63944973fc 100755
--- a/tools/push-to-trunk/push_to_trunk.py
+++ b/tools/push-to-trunk/push_to_trunk.py
@@ -55,35 +55,6 @@ PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)"
PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
-class PushToTrunkOptions(CommonOptions):
- @staticmethod
- def MakeForcedOptions(author, reviewer, chrome_path):
- """Convenience wrapper."""
- class Options(object):
- pass
- options = Options()
- options.step = 0
- options.last_push = None
- options.last_bleeding_edge = None
- options.force = True
- options.manual = False
- options.chromium = chrome_path
- options.reviewer = reviewer
- options.author = author
- return PushToTrunkOptions(options)
-
- def __init__(self, options):
- super(PushToTrunkOptions, self).__init__(options, options.manual)
- self.requires_editor = not options.force
- self.wait_for_lgtm = not options.force
- self.tbr_commit = not options.manual
- self.last_push = options.last_push
- self.reviewer = options.reviewer
- self.chromium = options.chromium
- self.last_bleeding_edge = getattr(options, 'last_bleeding_edge', None)
- self.author = getattr(options, 'author', None)
-
-
class Preparation(Step):
MESSAGE = "Preparation."
@@ -511,90 +482,67 @@ class CleanUp(Step):
self.GitDeleteBranch(self.Config(TRUNKBRANCH))
-def RunPushToTrunk(config,
- options,
- side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
- step_classes = [
- Preparation,
- FreshBranch,
- DetectLastPush,
- PrepareChangeLog,
- EditChangeLog,
- IncrementVersion,
- CommitLocal,
- UploadStep,
- CommitRepository,
- StragglerCommits,
- SquashCommits,
- NewBranch,
- ApplyChanges,
- SetVersion,
- CommitTrunk,
- SanityCheck,
- CommitSVN,
- TagRevision,
- CheckChromium,
- SwitchChromium,
- UpdateChromiumCheckout,
- UploadCL,
- SwitchV8,
- CleanUp,
- ]
-
- RunScript(step_classes, config, options, side_effect_handler)
-
-
-def BuildOptions():
- parser = argparse.ArgumentParser()
- group = parser.add_mutually_exclusive_group()
- group.add_argument("-f", "--force",
- help="Don't prompt the user.",
- default=False, action="store_true")
- group.add_argument("-m", "--manual",
- help="Prompt the user at every important step.",
- default=False, action="store_true")
- parser.add_argument("-a", "--author",
- help="The author email used for rietveld.")
- parser.add_argument("-b", "--last-bleeding-edge",
- help=("The git commit ID of the last bleeding edge "
- "revision that was pushed to trunk. This is used "
- "for the auto-generated ChangeLog entry."))
- parser.add_argument("-c", "--chromium",
- help=("The path to your Chromium src/ directory to "
- "automate the V8 roll."))
- parser.add_argument("-l", "--last-push",
- help="The git commit ID of the last push to trunk.")
- parser.add_argument("-r", "--reviewer",
- help="The account name to be used for reviews.")
- parser.add_argument("-s", "--step",
- help="The step where to start work. Default: 0.",
- default=0, type=int)
- return parser
-
-
-def ProcessOptions(options):
- if options.step < 0:
- print "Bad step number %d" % options.step
- return False
- if not options.manual and not options.reviewer:
- print "A reviewer (-r) is required in (semi-)automatic mode."
- return False
- if not options.manual and not options.chromium:
- print "A chromium checkout (-c) is required in (semi-)automatic mode."
- return False
- if not options.manual and not options.author:
- print "Specify your chromium.org email with -a in (semi-)automatic mode."
- return False
- return True
-
-
-def Main():
- parser = BuildOptions()
- options = parser.parse_args()
- if not ProcessOptions(options):
- parser.print_help()
- return 1
- RunPushToTrunk(CONFIG, PushToTrunkOptions(options))
+class PushToTrunk(ScriptsBase):
+ def _PrepareOptions(self, parser):
+ group = parser.add_mutually_exclusive_group()
+ group.add_argument("-f", "--force",
+ help="Don't prompt the user.",
+ default=False, action="store_true")
+ group.add_argument("-m", "--manual",
+ help="Prompt the user at every important step.",
+ default=False, action="store_true")
+ parser.add_argument("-b", "--last-bleeding-edge",
+ help=("The git commit ID of the last bleeding edge "
+ "revision that was pushed to trunk. This is "
+ "used for the auto-generated ChangeLog entry."))
+ parser.add_argument("-c", "--chromium",
+ help=("The path to your Chromium src/ "
+ "directory to automate the V8 roll."))
+ parser.add_argument("-l", "--last-push",
+ help="The git commit ID of the last push to trunk.")
+
+ def _ProcessOptions(self, options):
+ if not options.manual and not options.reviewer:
+ print "A reviewer (-r) is required in (semi-)automatic mode."
+ return False
+ if not options.manual and not options.chromium:
+ print "A chromium checkout (-c) is required in (semi-)automatic mode."
+ return False
+ if not options.manual and not options.author:
+ print "Specify your chromium.org email with -a in (semi-)automatic mode."
+ return False
+
+ options.tbr_commit = not options.manual
+ return True
+
+ def _Steps(self):
+ return [
+ Preparation,
+ FreshBranch,
+ DetectLastPush,
+ PrepareChangeLog,
+ EditChangeLog,
+ IncrementVersion,
+ CommitLocal,
+ UploadStep,
+ CommitRepository,
+ StragglerCommits,
+ SquashCommits,
+ NewBranch,
+ ApplyChanges,
+ SetVersion,
+ CommitTrunk,
+ SanityCheck,
+ CommitSVN,
+ TagRevision,
+ CheckChromium,
+ SwitchChromium,
+ UpdateChromiumCheckout,
+ UploadCL,
+ SwitchV8,
+ CleanUp,
+ ]
+
if __name__ == "__main__":
- sys.exit(Main())
+ sys.exit(PushToTrunk(CONFIG).Run())
« 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