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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 | 221 |
222 class CommonOptions(object): | 222 class CommonOptions(object): |
223 def __init__(self, options, manual=True): | 223 def __init__(self, options, manual=True): |
224 self.requires_editor = True | 224 self.requires_editor = True |
225 self.wait_for_lgtm = True | 225 self.wait_for_lgtm = True |
226 self.s = options.s | 226 self.s = options.s |
227 self.force_readline_defaults = not manual | 227 self.force_readline_defaults = not manual |
228 self.force_upload = not manual | 228 self.force_upload = not manual |
229 self.manual = manual | 229 self.manual = manual |
| 230 self.reviewer = getattr(options, 'reviewer', None) |
230 self.author = getattr(options, 'a', None) | 231 self.author = getattr(options, 'a', None) |
231 | 232 |
232 | 233 |
233 class Step(object): | 234 class Step(object): |
234 def __init__(self, text, requires, number, config, state, options, handler): | 235 def __init__(self, text, requires, number, config, state, options, handler): |
235 self._text = text | 236 self._text = text |
236 self._requires = requires | 237 self._requires = requires |
237 self._number = number | 238 self._number = number |
238 self._config = config | 239 self._config = config |
239 self._state = state | 240 self._state = state |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if self._options.force_readline_defaults and default is not None: | 296 if self._options.force_readline_defaults and default is not None: |
296 print "%s (forced)" % default | 297 print "%s (forced)" % default |
297 return default | 298 return default |
298 else: | 299 else: |
299 return self._side_effect_handler.ReadLine() | 300 return self._side_effect_handler.ReadLine() |
300 | 301 |
301 def Git(self, args="", prefix="", pipe=True, retry_on=None): | 302 def Git(self, args="", prefix="", pipe=True, retry_on=None): |
302 cmd = lambda: self._side_effect_handler.Command("git", args, prefix, pipe) | 303 cmd = lambda: self._side_effect_handler.Command("git", args, prefix, pipe) |
303 return self.Retry(cmd, retry_on, [5, 30]) | 304 return self.Retry(cmd, retry_on, [5, 30]) |
304 | 305 |
| 306 def SVN(self, args="", prefix="", pipe=True, retry_on=None): |
| 307 cmd = lambda: self._side_effect_handler.Command("svn", args, prefix, pipe) |
| 308 return self.Retry(cmd, retry_on, [5, 30]) |
| 309 |
305 def Editor(self, args): | 310 def Editor(self, args): |
306 if self._options.requires_editor: | 311 if self._options.requires_editor: |
307 return self._side_effect_handler.Command(os.environ["EDITOR"], args, | 312 return self._side_effect_handler.Command(os.environ["EDITOR"], args, |
308 pipe=False) | 313 pipe=False) |
309 | 314 |
310 def ReadURL(self, url, params=None, retry_on=None, wait_plan=None): | 315 def ReadURL(self, url, params=None, retry_on=None, wait_plan=None): |
311 wait_plan = wait_plan or [3, 60, 600] | 316 wait_plan = wait_plan or [3, 60, 600] |
312 cmd = lambda: self._side_effect_handler.ReadURL(url, params) | 317 cmd = lambda: self._side_effect_handler.ReadURL(url, params) |
313 return self.Retry(cmd, retry_on, wait_plan) | 318 return self.Retry(cmd, retry_on, wait_plan) |
314 | 319 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 def ApplyPatch(self, patch_file, reverse_patch=""): | 460 def ApplyPatch(self, patch_file, reverse_patch=""): |
456 args = "apply --index --reject %s \"%s\"" % (reverse_patch, patch_file) | 461 args = "apply --index --reject %s \"%s\"" % (reverse_patch, patch_file) |
457 if self.Git(args) is None: | 462 if self.Git(args) is None: |
458 self.WaitForResolvingConflicts(patch_file) | 463 self.WaitForResolvingConflicts(patch_file) |
459 | 464 |
460 | 465 |
461 class UploadStep(Step): | 466 class UploadStep(Step): |
462 MESSAGE = "Upload for code review." | 467 MESSAGE = "Upload for code review." |
463 | 468 |
464 def RunStep(self): | 469 def RunStep(self): |
465 if self._options.r: | 470 if self._options.reviewer: |
466 print "Using account %s for review." % self._options.r | 471 print "Using account %s for review." % self._options.reviewer |
467 reviewer = self._options.r | 472 reviewer = self._options.reviewer |
468 else: | 473 else: |
469 print "Please enter the email address of a V8 reviewer for your patch: ", | 474 print "Please enter the email address of a V8 reviewer for your patch: ", |
470 self.DieNoManualMode("A reviewer must be specified in forced mode.") | 475 self.DieNoManualMode("A reviewer must be specified in forced mode.") |
471 reviewer = self.ReadLine() | 476 reviewer = self.ReadLine() |
472 author_option = self._options.author | 477 author_option = self._options.author |
473 author = " --email \"%s\"" % author_option if author_option else "" | 478 author = " --email \"%s\"" % author_option if author_option else "" |
474 force_flag = " -f" if self._options.force_upload else "" | 479 force_flag = " -f" if self._options.force_upload else "" |
475 args = ("cl upload%s -r \"%s\" --send-mail%s" | 480 args = ("cl upload%s -r \"%s\" --send-mail%s" |
476 % (author, reviewer, force_flag)) | 481 % (author, reviewer, force_flag)) |
477 # TODO(machenbach): Check output in forced mode. Verify that all required | 482 # TODO(machenbach): Check output in forced mode. Verify that all required |
(...skipping 27 matching lines...) Expand all Loading... |
505 options, | 510 options, |
506 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 511 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
507 state = {} | 512 state = {} |
508 steps = [] | 513 steps = [] |
509 for (number, step_class) in enumerate(step_classes): | 514 for (number, step_class) in enumerate(step_classes): |
510 steps.append(MakeStep(step_class, number, state, config, | 515 steps.append(MakeStep(step_class, number, state, config, |
511 options, side_effect_handler)) | 516 options, side_effect_handler)) |
512 | 517 |
513 for step in steps[options.s:]: | 518 for step in steps[options.s:]: |
514 step.Run() | 519 step.Run() |
OLD | NEW |