| OLD | NEW |
| 1 # Copyright (C) 2009 Google Inc. All rights reserved. | 1 # Copyright (C) 2009 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 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 disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import logging | 29 import logging |
| 30 import sys | 30 import sys |
| 31 | 31 |
| 32 from webkitpy.tool import steps | 32 from webkitpy.tool.steps.options import Options |
| 33 | 33 |
| 34 from webkitpy.common.system.executive import ScriptError | 34 from webkitpy.common.system.executive import ScriptError |
| 35 | 35 |
| 36 _log = logging.getLogger(__name__) | 36 _log = logging.getLogger(__name__) |
| 37 | 37 |
| 38 | 38 |
| 39 class StepSequenceErrorHandler(): | 39 class StepSequenceErrorHandler(): |
| 40 | 40 |
| 41 @classmethod | 41 @classmethod |
| 42 def handle_script_error(cls, tool, patch, script_error): | 42 def handle_script_error(cls, tool, patch, script_error): |
| 43 raise NotImplementedError, "subclasses must implement" | 43 raise NotImplementedError, "subclasses must implement" |
| 44 | 44 |
| 45 @classmethod | 45 @classmethod |
| 46 def handle_checkout_needs_update(cls, tool, state, options, error): | 46 def handle_checkout_needs_update(cls, tool, state, options, error): |
| 47 raise NotImplementedError, "subclasses must implement" | 47 raise NotImplementedError, "subclasses must implement" |
| 48 | 48 |
| 49 | 49 |
| 50 class StepSequence(object): | 50 class StepSequence(object): |
| 51 | 51 |
| 52 def __init__(self, steps): | 52 def __init__(self, steps): |
| 53 self._steps = steps or [] | 53 self._steps = steps or [] |
| 54 | 54 |
| 55 def options(self): | 55 def options(self): |
| 56 collected_options = [ | 56 collected_options = [ |
| 57 steps.Options.parent_command, | 57 Options.parent_command, |
| 58 steps.Options.quiet, | 58 Options.quiet, |
| 59 ] | 59 ] |
| 60 for step in self._steps: | 60 for step in self._steps: |
| 61 collected_options = collected_options + step.options() | 61 collected_options = collected_options + step.options() |
| 62 # Remove duplicates. | 62 # Remove duplicates. |
| 63 collected_options = sorted(set(collected_options)) | 63 collected_options = sorted(set(collected_options)) |
| 64 return collected_options | 64 return collected_options |
| 65 | 65 |
| 66 def _run(self, tool, options, state): | 66 def _run(self, tool, options, state): |
| 67 for step in self._steps: | 67 for step in self._steps: |
| 68 step(tool, options).run(state) | 68 step(tool, options).run(state) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 80 state = {} | 80 state = {} |
| 81 try: | 81 try: |
| 82 self._run(tool, options, state) | 82 self._run(tool, options, state) |
| 83 except ScriptError, e: | 83 except ScriptError, e: |
| 84 if not options.quiet: | 84 if not options.quiet: |
| 85 _log.error(e.message_with_output()) | 85 _log.error(e.message_with_output()) |
| 86 if options.parent_command: | 86 if options.parent_command: |
| 87 command = tool.command_by_name(options.parent_command) | 87 command = tool.command_by_name(options.parent_command) |
| 88 command.handle_script_error(tool, state, e) | 88 command.handle_script_error(tool, state, e) |
| 89 self.exit_after_handled_error(e) | 89 self.exit_after_handled_error(e) |
| OLD | NEW |