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 |
11 # in the documentation and/or other materials provided with the | 11 # in the documentation and/or other materials provided with the |
12 # distribution. | 12 # distribution. |
13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
14 # contributors may be used to endorse or promote products derived from | 14 # contributors may be used to endorse or promote products derived from |
15 # this software without specific prior written permission. | 15 # this software without specific prior written permission. |
16 # | 16 # |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
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 | 31 |
31 from webkitpy.tool import steps | 32 from webkitpy.tool import steps |
32 | 33 |
33 from webkitpy.common.checkout.scm import CheckoutNeedsUpdate | 34 from webkitpy.common.checkout.scm import CheckoutNeedsUpdate |
34 from webkitpy.common.system.executive import ScriptError | 35 from webkitpy.common.system.executive import ScriptError |
35 from webkitpy.tool.bot.queueengine import QueueEngine | |
36 | 36 |
37 _log = logging.getLogger(__name__) | 37 _log = logging.getLogger(__name__) |
38 | 38 |
39 | 39 |
40 class StepSequenceErrorHandler(): | 40 class StepSequenceErrorHandler(): |
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 |
(...skipping 13 matching lines...) Expand all Loading... |
59 for step in self._steps: | 59 for step in self._steps: |
60 collected_options = collected_options + step.options() | 60 collected_options = collected_options + step.options() |
61 # Remove duplicates. | 61 # Remove duplicates. |
62 collected_options = sorted(set(collected_options)) | 62 collected_options = sorted(set(collected_options)) |
63 return collected_options | 63 return collected_options |
64 | 64 |
65 def _run(self, tool, options, state): | 65 def _run(self, tool, options, state): |
66 for step in self._steps: | 66 for step in self._steps: |
67 step(tool, options).run(state) | 67 step(tool, options).run(state) |
68 | 68 |
| 69 # Child processes exit with a special code to the parent queue process can d
etect the error was handled. |
| 70 handled_error_code = 2 |
| 71 |
| 72 @classmethod |
| 73 def exit_after_handled_error(cls, error): |
| 74 _log.error(error) |
| 75 sys.exit(cls.handled_error_code) |
| 76 |
69 def run_and_handle_errors(self, tool, options, state=None): | 77 def run_and_handle_errors(self, tool, options, state=None): |
70 if not state: | 78 if not state: |
71 state = {} | 79 state = {} |
72 try: | 80 try: |
73 self._run(tool, options, state) | 81 self._run(tool, options, state) |
74 except CheckoutNeedsUpdate, e: | 82 except CheckoutNeedsUpdate, e: |
75 _log.info("Commit failed because the checkout is out of date. Please
update and try again.") | 83 _log.info("Commit failed because the checkout is out of date. Please
update and try again.") |
76 if options.parent_command: | 84 if options.parent_command: |
77 command = tool.command_by_name(options.parent_command) | 85 command = tool.command_by_name(options.parent_command) |
78 command.handle_checkout_needs_update(tool, state, options, e) | 86 command.handle_checkout_needs_update(tool, state, options, e) |
79 QueueEngine.exit_after_handled_error(e) | 87 self.exit_after_handled_error(e) |
80 except ScriptError, e: | 88 except ScriptError, e: |
81 if not options.quiet: | 89 if not options.quiet: |
82 _log.error(e.message_with_output()) | 90 _log.error(e.message_with_output()) |
83 if options.parent_command: | 91 if options.parent_command: |
84 command = tool.command_by_name(options.parent_command) | 92 command = tool.command_by_name(options.parent_command) |
85 command.handle_script_error(tool, state, e) | 93 command.handle_script_error(tool, state, e) |
86 QueueEngine.exit_after_handled_error(e) | 94 self.exit_after_handled_error(e) |
OLD | NEW |