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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 match = re.match(r"^## (.+)", line) | 237 match = re.match(r"^## (.+)", line) |
238 if match: | 238 if match: |
239 current_branch = match.group(1) | 239 current_branch = match.group(1) |
240 break | 240 break |
241 self.Persist("current_branch", current_branch) | 241 self.Persist("current_branch", current_branch) |
242 | 242 |
243 # Fetch unfetched revisions. | 243 # Fetch unfetched revisions. |
244 if self.Git("svn fetch") is None: | 244 if self.Git("svn fetch") is None: |
245 self.Die("'git svn fetch' failed.") | 245 self.Die("'git svn fetch' failed.") |
246 | 246 |
| 247 def PrepareBranch(self): |
247 # Get ahold of a safe temporary branch and check it out. | 248 # Get ahold of a safe temporary branch and check it out. |
248 if current_branch != self._config[TEMP_BRANCH]: | 249 self.RestoreIfUnset("current_branch") |
| 250 if self._state["current_branch"] != self._config[TEMP_BRANCH]: |
249 self.DeleteBranch(self._config[TEMP_BRANCH]) | 251 self.DeleteBranch(self._config[TEMP_BRANCH]) |
250 self.Git("checkout -b %s" % self._config[TEMP_BRANCH]) | 252 self.Git("checkout -b %s" % self._config[TEMP_BRANCH]) |
251 | 253 |
252 # Delete the branch that will be created later if it exists already. | 254 # Delete the branch that will be created later if it exists already. |
253 self.DeleteBranch(self._config[BRANCHNAME]) | 255 self.DeleteBranch(self._config[BRANCHNAME]) |
254 | 256 |
255 def CommonCleanup(self): | 257 def CommonCleanup(self): |
256 self.RestoreIfUnset("current_branch") | 258 self.RestoreIfUnset("current_branch") |
257 self.Git("checkout -f %s" % self._state["current_branch"]) | 259 self.Git("checkout -f %s" % self._state["current_branch"]) |
258 if self._config[TEMP_BRANCH] != self._state["current_branch"]: | 260 if self._config[TEMP_BRANCH] != self._state["current_branch"]: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 class UploadStep(Step): | 318 class UploadStep(Step): |
317 def __init__(self): | 319 def __init__(self): |
318 Step.__init__(self, "Upload for code review.") | 320 Step.__init__(self, "Upload for code review.") |
319 | 321 |
320 def RunStep(self): | 322 def RunStep(self): |
321 print "Please enter the email address of a V8 reviewer for your patch: ", | 323 print "Please enter the email address of a V8 reviewer for your patch: ", |
322 reviewer = self.ReadLine() | 324 reviewer = self.ReadLine() |
323 args = "cl upload -r \"%s\" --send-mail" % reviewer | 325 args = "cl upload -r \"%s\" --send-mail" % reviewer |
324 if self.Git(args,pipe=False) is None: | 326 if self.Git(args,pipe=False) is None: |
325 self.Die("'git cl upload' failed, please try again.") | 327 self.Die("'git cl upload' failed, please try again.") |
| 328 |
| 329 |
| 330 def RunScript(step_classes, |
| 331 config, |
| 332 options, |
| 333 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
| 334 state = {} |
| 335 steps = [] |
| 336 number = 0 |
| 337 |
| 338 for step_class in step_classes: |
| 339 # TODO(machenbach): Factory methods. |
| 340 step = step_class() |
| 341 step.SetNumber(number) |
| 342 step.SetConfig(config) |
| 343 step.SetOptions(options) |
| 344 step.SetState(state) |
| 345 step.SetSideEffectHandler(side_effect_handler) |
| 346 steps.append(step) |
| 347 number += 1 |
| 348 |
| 349 for step in steps[options.s:]: |
| 350 step.Run() |
OLD | NEW |