| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 usage = "Usage: %prog [options] COMMAND [ARGS]" | 145 usage = "Usage: %prog [options] COMMAND [ARGS]" |
| 146 name = optparse.OptionParser().get_prog_name() | 146 name = optparse.OptionParser().get_prog_name() |
| 147 return HelpPrintingOptionParser(epilog_method=self.help_command.help_epi
log, prog=name, usage=usage) | 147 return HelpPrintingOptionParser(epilog_method=self.help_command.help_epi
log, prog=name, usage=usage) |
| 148 | 148 |
| 149 def _add_global_options(self, option_parser): | 149 def _add_global_options(self, option_parser): |
| 150 global_options = self.global_options or [] | 150 global_options = self.global_options or [] |
| 151 for option in global_options: | 151 for option in global_options: |
| 152 option_parser.add_option(option) | 152 option_parser.add_option(option) |
| 153 | 153 |
| 154 def _should_execute_command(self, command): | 154 def _should_execute_command(self, command): |
| 155 if command.requires_local_commits and not self.scm().supports_local_comm
its(): | 155 if command.requires_local_commits and not self.git().supports_local_comm
its(): |
| 156 failure_reason = "%s requires local commits using %s in %s." % ( | 156 failure_reason = "%s requires local commits using %s in %s." % ( |
| 157 command.name, self.scm().display_name(), self.scm().checkout_roo
t) | 157 command.name, self.git().display_name(), self.git().checkout_roo
t) |
| 158 return (False, failure_reason) | 158 return (False, failure_reason) |
| 159 return (True, None) | 159 return (True, None) |
| 160 | 160 |
| 161 def name(self): | 161 def name(self): |
| 162 return optparse.OptionParser().get_prog_name() | 162 return optparse.OptionParser().get_prog_name() |
| 163 | 163 |
| 164 def should_show_in_main_help(self, command): | 164 def should_show_in_main_help(self, command): |
| 165 if not command.show_in_main_help: | 165 if not command.show_in_main_help: |
| 166 return False | 166 return False |
| 167 if command.requires_local_commits: | 167 if command.requires_local_commits: |
| 168 return self.scm().supports_local_commits() | 168 return self.git().supports_local_commits() |
| 169 return True | 169 return True |
| 170 | 170 |
| 171 def command_by_name(self, command_name): | 171 def command_by_name(self, command_name): |
| 172 for command in self.commands: | 172 for command in self.commands: |
| 173 if command_name == command.name: | 173 if command_name == command.name: |
| 174 return command | 174 return command |
| 175 return None | 175 return None |
| OLD | NEW |