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

Side by Side Diff: tools/push-to-trunk/auto_roll.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 | « no previous file | tools/push-to-trunk/common_includes.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 17 matching lines...) Expand all
28 28
29 import argparse 29 import argparse
30 import json 30 import json
31 import os 31 import os
32 import re 32 import re
33 import sys 33 import sys
34 import urllib 34 import urllib
35 35
36 from common_includes import * 36 from common_includes import *
37 import push_to_trunk 37 import push_to_trunk
38 from push_to_trunk import PushToTrunkOptions
39 from push_to_trunk import RunPushToTrunk
40 38
41 SETTINGS_LOCATION = "SETTINGS_LOCATION" 39 SETTINGS_LOCATION = "SETTINGS_LOCATION"
42 40
43 CONFIG = { 41 CONFIG = {
44 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", 42 PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
45 DOT_GIT_LOCATION: ".git", 43 DOT_GIT_LOCATION: ".git",
46 SETTINGS_LOCATION: "~/.auto-roll", 44 SETTINGS_LOCATION: "~/.auto-roll",
47 } 45 }
48 46
49 47
50 class AutoRollOptions(CommonOptions):
51 def __init__(self, options):
52 super(AutoRollOptions, self).__init__(options)
53 self.requires_editor = False
54 self.status_password = options.status_password
55 self.chromium = options.chromium
56 self.push = getattr(options, 'push', False)
57 self.author = getattr(options, 'author', None)
58
59
60 class Preparation(Step): 48 class Preparation(Step):
61 MESSAGE = "Preparation." 49 MESSAGE = "Preparation."
62 50
63 def RunStep(self): 51 def RunStep(self):
64 self.InitialEnvironmentChecks() 52 self.InitialEnvironmentChecks()
65 self.CommonPrepare() 53 self.CommonPrepare()
66 54
67 55
68 class CheckAutoRollSettings(Step): 56 class CheckAutoRollSettings(Step):
69 MESSAGE = "Checking settings file." 57 MESSAGE = "Checking settings file."
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 latest = int(self["latest"]) 132 latest = int(self["latest"])
145 lkgr = int(self["lkgr"]) 133 lkgr = int(self["lkgr"])
146 if latest == lkgr: 134 if latest == lkgr:
147 print "ToT (r%d) is clean. Pushing to trunk." % latest 135 print "ToT (r%d) is clean. Pushing to trunk." % latest
148 self.PushTreeStatus("Tree is closed (preparing to push)") 136 self.PushTreeStatus("Tree is closed (preparing to push)")
149 137
150 # TODO(machenbach): Update the script before calling it. 138 # TODO(machenbach): Update the script before calling it.
151 try: 139 try:
152 if self._options.push: 140 if self._options.push:
153 self._side_effect_handler.Call( 141 self._side_effect_handler.Call(
154 RunPushToTrunk, 142 PushToTrunk(push_to_trunk.CONFIG, self._side_effect_handler).Run,
155 push_to_trunk.CONFIG, 143 ["-a", self._options.author,
156 PushToTrunkOptions.MakeForcedOptions(self._options.author, 144 "-c", self._options.chromium,
157 self._options.reviewer, 145 "-r", self._options.reviewer,
158 self._options.chromium), 146 "-f"])
159 self._side_effect_handler)
160 finally: 147 finally:
161 self.PushTreeStatus(self["tree_message"]) 148 self.PushTreeStatus(self["tree_message"])
162 else: 149 else:
163 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk." 150 print("ToT (r%d) is ahead of the LKGR (r%d). Skipping push to trunk."
164 % (latest, lkgr)) 151 % (latest, lkgr))
165 152
166 153
167 def RunAutoRoll(config, 154 class AutoRoll(ScriptsBase):
168 options, 155 def _PrepareOptions(self, parser):
169 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): 156 parser.add_argument("-c", "--chromium", required=True,
170 step_classes = [ 157 help=("The path to your Chromium src/ "
171 Preparation, 158 "directory to automate the V8 roll."))
172 CheckAutoRollSettings, 159 parser.add_argument("-p", "--push",
173 CheckTreeStatus, 160 help="Push to trunk. Dry run if unspecified.",
174 FetchLatestRevision, 161 default=False, action="store_true")
175 CheckLastPush, 162 parser.add_argument("--status-password",
176 FetchLKGR, 163 help="A file with the password to the status app.")
177 PushToTrunk, 164
178 ] 165 def _ProcessOptions(self, options):
179 RunScript(step_classes, config, options, side_effect_handler) 166 if not options.author or not options.reviewer:
167 print "You need to specify author and reviewer."
168 return False
169 options.requires_editor = False
170 return True
171
172 def _Steps(self):
173 return [
174 Preparation,
175 CheckAutoRollSettings,
176 CheckTreeStatus,
177 FetchLatestRevision,
178 CheckLastPush,
179 FetchLKGR,
180 PushToTrunk,
181 ]
180 182
181 183
182 def BuildOptions():
183 parser = argparse.ArgumentParser()
184 parser.add_argument("-a", "--author",
185 help="The author email used for rietveld.")
186 parser.add_argument("-c", "--chromium",
187 help=("The path to your Chromium src/ directory to "
188 "automate the V8 roll."))
189 parser.add_argument("-p", "--push",
190 help="Push to trunk if possible. Dry run if unspecified.",
191 default=False, action="store_true")
192 parser.add_argument("-r", "--reviewer",
193 help="The account name to be used for reviews.")
194 parser.add_argument("-s", "--step",
195 help="Specify the step where to start work. Default: 0.",
196 default=0, type=int)
197 parser.add_argument("--status-password",
198 help="A file with the password to the status app.")
199 return parser
200
201
202 def Main():
203 parser = BuildOptions()
204 options = parser.parse_args()
205 if not options.author or not options.chromium or not options.reviewer:
206 print "You need to specify author, chromium src location and reviewer."
207 parser.print_help()
208 return 1
209 RunAutoRoll(CONFIG, AutoRollOptions(options))
210
211 if __name__ == "__main__": 184 if __name__ == "__main__":
212 sys.exit(Main()) 185 sys.exit(AutoRoll(CONFIG).Run())
OLDNEW
« no previous file with comments | « no previous file | tools/push-to-trunk/common_includes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698