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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 def Land(self): | 339 def Land(self): |
340 self.step.GitSVNDCommit() | 340 self.step.GitSVNDCommit() |
341 | 341 |
342 def CLLand(self): | 342 def CLLand(self): |
343 self.step.GitDCommit() | 343 self.step.GitDCommit() |
344 | 344 |
345 def Tag(self, tag): | 345 def Tag(self, tag): |
346 self.step.GitSVNTag(tag) | 346 self.step.GitSVNTag(tag) |
347 | 347 |
348 | 348 |
349 class GitReadOnlyMixin(VCInterface): | |
350 def Pull(self): | |
351 self.step.GitPull() | |
352 | |
353 def Fetch(self): | |
354 self.step.Git("fetch") | |
355 | |
356 def GetTags(self): | |
357 return self.step.Git("tag").strip().splitlines() | |
358 | |
359 def GetBranches(self): | |
360 # Get relevant remote branches, e.g. "origin/branch-heads/3.25". | |
361 branches = filter( | |
362 lambda s: re.match(r"^origin/branch\-heads/\d+\.\d+$", s), | |
363 self.step.GitRemotes()) | |
364 # Remove 'origin/branch-heads/' prefix. | |
365 return map(lambda s: s[20:], branches) | |
366 | |
367 def RemoteMasterBranch(self): | |
368 return "origin/master" | |
369 | |
370 def RemoteCandidateBranch(self): | |
371 return "origin/candidates" | |
372 | |
373 def RemoteBranch(self, name): | |
374 return "origin/branch-heads/%s" % name | |
375 | |
376 | |
377 class GitReadSvnWriteInterface(GitReadOnlyMixin, GitSvnInterface): | |
378 pass | |
379 | |
380 | |
381 VC_INTERFACES = { | |
382 "git_svn": GitSvnInterface, | |
383 "git_read_svn_write": GitReadSvnWriteInterface, | |
384 } | |
385 | |
349 | 386 |
350 class Step(GitRecipesMixin): | 387 class Step(GitRecipesMixin): |
351 def __init__(self, text, number, config, state, options, handler): | 388 def __init__(self, text, number, config, state, options, handler): |
352 self._text = text | 389 self._text = text |
353 self._number = number | 390 self._number = number |
354 self._config = config | 391 self._config = config |
355 self._state = state | 392 self._state = state |
356 self._options = options | 393 self._options = options |
357 self._side_effect_handler = handler | 394 self._side_effect_handler = handler |
358 self.vc = GitSvnInterface() | 395 self.vc = VC_INTERFACES[options.vc_port]() |
359 self.vc.InjectStep(self) | 396 self.vc.InjectStep(self) |
360 | 397 |
361 # The testing configuration might set a different default cwd. | 398 # The testing configuration might set a different default cwd. |
362 self.default_cwd = self._config.get("DEFAULT_CWD") or DEFAULT_CWD | 399 self.default_cwd = self._config.get("DEFAULT_CWD") or DEFAULT_CWD |
363 | 400 |
364 assert self._number >= 0 | 401 assert self._number >= 0 |
365 assert self._config is not None | 402 assert self._config is not None |
366 assert self._state is not None | 403 assert self._state is not None |
367 assert self._side_effect_handler is not None | 404 assert self._side_effect_handler is not None |
368 | 405 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 "success, this will overwrite the reviewer " | 770 "success, this will overwrite the reviewer " |
734 "option.")) | 771 "option.")) |
735 parser.add_argument("--svn", | 772 parser.add_argument("--svn", |
736 help=("Optional full svn checkout for the commit." | 773 help=("Optional full svn checkout for the commit." |
737 "The folder needs to be the svn root.")) | 774 "The folder needs to be the svn root.")) |
738 parser.add_argument("--svn-config", | 775 parser.add_argument("--svn-config", |
739 help=("Optional folder used as svn --config-dir.")) | 776 help=("Optional folder used as svn --config-dir.")) |
740 parser.add_argument("-s", "--step", | 777 parser.add_argument("-s", "--step", |
741 help="Specify the step where to start work. Default: 0.", | 778 help="Specify the step where to start work. Default: 0.", |
742 default=0, type=int) | 779 default=0, type=int) |
780 parser.add_argument("--vc-port", | |
tandrii(chromium)
2014/09/25 15:53:52
why "port" and not "interface"? Is it less typing?
| |
781 help=("Choose VC port out of git_svn|" | |
782 "git_read_svn_write.")) | |
743 self._PrepareOptions(parser) | 783 self._PrepareOptions(parser) |
744 | 784 |
745 if args is None: # pragma: no cover | 785 if args is None: # pragma: no cover |
746 options = parser.parse_args() | 786 options = parser.parse_args() |
747 else: | 787 else: |
748 options = parser.parse_args(args) | 788 options = parser.parse_args(args) |
749 | 789 |
750 # Process common options. | 790 # Process common options. |
751 if options.step < 0: # pragma: no cover | 791 if options.step < 0: # pragma: no cover |
752 print "Bad step number %d" % options.step | 792 print "Bad step number %d" % options.step |
(...skipping 16 matching lines...) Expand all Loading... | |
769 # Derived options. | 809 # Derived options. |
770 options.requires_editor = not options.force | 810 options.requires_editor = not options.force |
771 options.wait_for_lgtm = not options.force | 811 options.wait_for_lgtm = not options.force |
772 options.force_readline_defaults = not options.manual | 812 options.force_readline_defaults = not options.manual |
773 options.force_upload = not options.manual | 813 options.force_upload = not options.manual |
774 | 814 |
775 # Process script specific options. | 815 # Process script specific options. |
776 if not self._ProcessOptions(options): | 816 if not self._ProcessOptions(options): |
777 parser.print_help() | 817 parser.print_help() |
778 return None | 818 return None |
819 | |
820 if not options.vc_port: | |
821 options.vc_port = "git_svn" | |
779 return options | 822 return options |
780 | 823 |
781 def RunSteps(self, step_classes, args=None): | 824 def RunSteps(self, step_classes, args=None): |
782 options = self.MakeOptions(args) | 825 options = self.MakeOptions(args) |
783 if not options: | 826 if not options: |
784 return 1 | 827 return 1 |
785 | 828 |
786 state_file = "%s-state.json" % self._config["PERSISTFILE_BASENAME"] | 829 state_file = "%s-state.json" % self._config["PERSISTFILE_BASENAME"] |
787 if options.step == 0 and os.path.exists(state_file): | 830 if options.step == 0 and os.path.exists(state_file): |
788 os.remove(state_file) | 831 os.remove(state_file) |
789 | 832 |
790 steps = [] | 833 steps = [] |
791 for (number, step_class) in enumerate(step_classes): | 834 for (number, step_class) in enumerate(step_classes): |
792 steps.append(MakeStep(step_class, number, self._state, self._config, | 835 steps.append(MakeStep(step_class, number, self._state, self._config, |
793 options, self._side_effect_handler)) | 836 options, self._side_effect_handler)) |
794 for step in steps[options.step:]: | 837 for step in steps[options.step:]: |
795 if step.Run(): | 838 if step.Run(): |
796 return 0 | 839 return 0 |
797 return 0 | 840 return 0 |
798 | 841 |
799 def Run(self, args=None): | 842 def Run(self, args=None): |
800 return self.RunSteps(self._Steps(), args) | 843 return self.RunSteps(self._Steps(), args) |
OLD | NEW |