| 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 13 matching lines...) Expand all Loading... |
| 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 import steps |
| 33 | 33 |
| 34 from webkitpy.common.checkout.scm import CheckoutNeedsUpdate | |
| 35 from webkitpy.common.system.executive import ScriptError | 34 from webkitpy.common.system.executive import ScriptError |
| 36 | 35 |
| 37 _log = logging.getLogger(__name__) | 36 _log = logging.getLogger(__name__) |
| 38 | 37 |
| 39 | 38 |
| 40 class StepSequenceErrorHandler(): | 39 class StepSequenceErrorHandler(): |
| 41 @classmethod | 40 @classmethod |
| 42 def handle_script_error(cls, tool, patch, script_error): | 41 def handle_script_error(cls, tool, patch, script_error): |
| 43 raise NotImplementedError, "subclasses must implement" | 42 raise NotImplementedError, "subclasses must implement" |
| 44 | 43 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 @classmethod | 71 @classmethod |
| 73 def exit_after_handled_error(cls, error): | 72 def exit_after_handled_error(cls, error): |
| 74 _log.error(error) | 73 _log.error(error) |
| 75 sys.exit(cls.handled_error_code) | 74 sys.exit(cls.handled_error_code) |
| 76 | 75 |
| 77 def run_and_handle_errors(self, tool, options, state=None): | 76 def run_and_handle_errors(self, tool, options, state=None): |
| 78 if not state: | 77 if not state: |
| 79 state = {} | 78 state = {} |
| 80 try: | 79 try: |
| 81 self._run(tool, options, state) | 80 self._run(tool, options, state) |
| 82 except CheckoutNeedsUpdate, e: | |
| 83 _log.info("Commit failed because the checkout is out of date. Please
update and try again.") | |
| 84 if options.parent_command: | |
| 85 command = tool.command_by_name(options.parent_command) | |
| 86 command.handle_checkout_needs_update(tool, state, options, e) | |
| 87 self.exit_after_handled_error(e) | |
| 88 except ScriptError, e: | 81 except ScriptError, e: |
| 89 if not options.quiet: | 82 if not options.quiet: |
| 90 _log.error(e.message_with_output()) | 83 _log.error(e.message_with_output()) |
| 91 if options.parent_command: | 84 if options.parent_command: |
| 92 command = tool.command_by_name(options.parent_command) | 85 command = tool.command_by_name(options.parent_command) |
| 93 command.handle_script_error(tool, state, e) | 86 command.handle_script_error(tool, state, e) |
| 94 self.exit_after_handled_error(e) | 87 self.exit_after_handled_error(e) |
| OLD | NEW |