| OLD | NEW |
| 1 # Copyright (c) 2010 Google Inc. All rights reserved. | 1 # Copyright (c) 2010 Google Inc. All rights reserved. |
| 2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 option_parser = self._create_option_parser() | 106 option_parser = self._create_option_parser() |
| 107 self._add_global_options(option_parser) | 107 self._add_global_options(option_parser) |
| 108 | 108 |
| 109 command = self.command_by_name(command_name) or self.help_command | 109 command = self.command_by_name(command_name) or self.help_command |
| 110 if not command: | 110 if not command: |
| 111 option_parser.error("%s is not a recognized command", command_name) | 111 option_parser.error("%s is not a recognized command", command_name) |
| 112 | 112 |
| 113 command.set_option_parser(option_parser) | 113 command.set_option_parser(option_parser) |
| 114 (options, args) = command.parse_args(args) | 114 (options, args) = command.parse_args(args) |
| 115 self.initialize_scm() | |
| 116 | 115 |
| 117 (should_execute, failure_reason) = self._should_execute_command(command) | 116 (should_execute, failure_reason) = self._should_execute_command(command) |
| 118 if not should_execute: | 117 if not should_execute: |
| 119 _log.error(failure_reason) | 118 _log.error(failure_reason) |
| 120 return 0 # FIXME: Should this really be 0? | 119 return 0 # FIXME: Should this really be 0? |
| 121 | 120 |
| 122 result = command.check_arguments_and_execute(options, args, self) | 121 result = command.check_arguments_and_execute(options, args, self) |
| 123 return result | 122 return result |
| 124 | 123 |
| 125 def path(self): | 124 def path(self): |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 return False | 163 return False |
| 165 if command.requires_local_commits: | 164 if command.requires_local_commits: |
| 166 return self.scm().supports_local_commits() | 165 return self.scm().supports_local_commits() |
| 167 return True | 166 return True |
| 168 | 167 |
| 169 def command_by_name(self, command_name): | 168 def command_by_name(self, command_name): |
| 170 for command in self.commands: | 169 for command in self.commands: |
| 171 if command_name == command.name: | 170 if command_name == command.name: |
| 172 return command | 171 return command |
| 173 return None | 172 return None |
| OLD | NEW |