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 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 print "Nothing to format." | 2174 print "Nothing to format." |
2175 return 0 | 2175 return 0 |
2176 RunCommand(['clang-format', '-i', '-style', 'Chromium'] + files, | 2176 RunCommand(['clang-format', '-i', '-style', 'Chromium'] + files, |
2177 cwd=top_dir) | 2177 cwd=top_dir) |
2178 else: | 2178 else: |
2179 # diff_output is a patch to send to clang-format-diff.py | 2179 # diff_output is a patch to send to clang-format-diff.py |
2180 cfd_path = os.path.join('/usr', 'lib', 'clang-format', | 2180 cfd_path = os.path.join('/usr', 'lib', 'clang-format', |
2181 'clang-format-diff.py') | 2181 'clang-format-diff.py') |
2182 if not os.path.exists(cfd_path): | 2182 if not os.path.exists(cfd_path): |
2183 DieWithError('Could not find clang-format-diff at %s.' % cfd_path) | 2183 DieWithError('Could not find clang-format-diff at %s.' % cfd_path) |
2184 cmd = [sys.executable, cfd_path, '-style', 'Chromium'] | 2184 cmd = [sys.executable, cfd_path, '-p0', '-style', 'Chromium'] |
2185 RunCommand(cmd, stdin=diff_output, cwd=top_dir) | 2185 RunCommand(cmd, stdin=diff_output, cwd=top_dir) |
2186 | 2186 |
2187 return 0 | 2187 return 0 |
2188 | 2188 |
2189 | 2189 |
2190 class OptionParser(optparse.OptionParser): | 2190 class OptionParser(optparse.OptionParser): |
2191 """Creates the option parse and add --verbose support.""" | 2191 """Creates the option parse and add --verbose support.""" |
2192 def __init__(self, *args, **kwargs): | 2192 def __init__(self, *args, **kwargs): |
2193 optparse.OptionParser.__init__( | 2193 optparse.OptionParser.__init__( |
2194 self, *args, prog='git cl', version=__version__, **kwargs) | 2194 self, *args, prog='git cl', version=__version__, **kwargs) |
(...skipping 30 matching lines...) Expand all Loading... |
2225 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2225 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2226 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2226 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2227 | 2227 |
2228 | 2228 |
2229 if __name__ == '__main__': | 2229 if __name__ == '__main__': |
2230 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2230 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2231 # unit testing. | 2231 # unit testing. |
2232 fix_encoding.fix_encoding() | 2232 fix_encoding.fix_encoding() |
2233 colorama.init() | 2233 colorama.init() |
2234 sys.exit(main(sys.argv[1:])) | 2234 sys.exit(main(sys.argv[1:])) |
OLD | NEW |