| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2149 self.add_option( | 2149 self.add_option( |
| 2150 '-v', '--verbose', action='count', default=0, | 2150 '-v', '--verbose', action='count', default=0, |
| 2151 help='Use 2 times for more debugging info') | 2151 help='Use 2 times for more debugging info') |
| 2152 | 2152 |
| 2153 def parse_args(self, args=None, values=None): | 2153 def parse_args(self, args=None, values=None): |
| 2154 options, args = optparse.OptionParser.parse_args(self, args, values) | 2154 options, args = optparse.OptionParser.parse_args(self, args, values) |
| 2155 levels = [logging.WARNING, logging.INFO, logging.DEBUG] | 2155 levels = [logging.WARNING, logging.INFO, logging.DEBUG] |
| 2156 logging.basicConfig(level=levels[min(options.verbose, len(levels) - 1)]) | 2156 logging.basicConfig(level=levels[min(options.verbose, len(levels) - 1)]) |
| 2157 return options, args | 2157 return options, args |
| 2158 | 2158 |
| 2159 def format_description(self, _): | |
| 2160 """Disables automatic reformatting.""" | |
| 2161 lines = self.description.rstrip().splitlines() | |
| 2162 lines_fixed = [lines[0]] + [l[2:] if len(l) >= 2 else l for l in lines[1:]] | |
| 2163 description = ''.join(l + '\n' for l in lines_fixed) | |
| 2164 return description[0].upper() + description[1:] | |
| 2165 | |
| 2166 | 2159 |
| 2167 def main(argv): | 2160 def main(argv): |
| 2168 if sys.hexversion < 0x02060000: | 2161 if sys.hexversion < 0x02060000: |
| 2169 print >> sys.stderr, ( | 2162 print >> sys.stderr, ( |
| 2170 '\nYour python version %s is unsupported, please upgrade.\n' % | 2163 '\nYour python version %s is unsupported, please upgrade.\n' % |
| 2171 sys.version.split(' ', 1)[0]) | 2164 sys.version.split(' ', 1)[0]) |
| 2172 return 2 | 2165 return 2 |
| 2173 | 2166 |
| 2174 # Reload settings. | 2167 # Reload settings. |
| 2175 global settings | 2168 global settings |
| 2176 settings = Settings() | 2169 settings = Settings() |
| 2177 | 2170 |
| 2178 dispatcher = subcommand.CommandDispatcher(__name__) | 2171 dispatcher = subcommand.CommandDispatcher(__name__) |
| 2179 try: | 2172 try: |
| 2180 return dispatcher.execute(OptionParser(), argv) | 2173 return dispatcher.execute(OptionParser(), argv) |
| 2181 except urllib2.HTTPError, e: | 2174 except urllib2.HTTPError, e: |
| 2182 if e.code != 500: | 2175 if e.code != 500: |
| 2183 raise | 2176 raise |
| 2184 DieWithError( | 2177 DieWithError( |
| 2185 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2178 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2186 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2179 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2187 | 2180 |
| 2188 | 2181 |
| 2189 if __name__ == '__main__': | 2182 if __name__ == '__main__': |
| 2190 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2183 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2191 # unit testing. | 2184 # unit testing. |
| 2192 fix_encoding.fix_encoding() | 2185 fix_encoding.fix_encoding() |
| 2193 colorama.init() | 2186 colorama.init() |
| 2194 sys.exit(main(sys.argv[1:])) | 2187 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |