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 def main(self, argv=None): | 106 def main(self, argv=None): |
107 argv = argv or sys.argv | 107 argv = argv or sys.argv |
108 (command_name, args) = self._split_command_name_from_args(argv[1:]) | 108 (command_name, args) = self._split_command_name_from_args(argv[1:]) |
109 | 109 |
110 option_parser = self._create_option_parser() | 110 option_parser = self._create_option_parser() |
111 self._add_global_options(option_parser) | 111 self._add_global_options(option_parser) |
112 | 112 |
113 command = self.command_by_name(command_name) or self.help_command | 113 command = self.command_by_name(command_name) or self.help_command |
114 if not command: | 114 if not command: |
115 option_parser.error("%s is not a recognized command" % command_name) | 115 option_parser.error("%s is not a recognized command", command_name) |
116 | 116 |
117 command.set_option_parser(option_parser) | 117 command.set_option_parser(option_parser) |
118 (options, args) = command.parse_args(args) | 118 (options, args) = command.parse_args(args) |
119 self._handle_global_options(options) | 119 self._handle_global_options(options) |
120 | 120 |
121 (should_execute, failure_reason) = self._should_execute_command(command) | 121 (should_execute, failure_reason) = self._should_execute_command(command) |
122 if not should_execute: | 122 if not should_execute: |
123 _log.error(failure_reason) | 123 _log.error(failure_reason) |
124 return 0 # FIXME: Should this really be 0? | 124 return 0 # FIXME: Should this really be 0? |
125 | 125 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return False | 172 return False |
173 if command.requires_local_commits: | 173 if command.requires_local_commits: |
174 return self.scm().supports_local_commits() | 174 return self.scm().supports_local_commits() |
175 return True | 175 return True |
176 | 176 |
177 def command_by_name(self, command_name): | 177 def command_by_name(self, command_name): |
178 for command in self.commands: | 178 for command in self.commands: |
179 if command_name == command.name: | 179 if command_name == command.name: |
180 return command | 180 return command |
181 return None | 181 return None |
OLD | NEW |