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 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 print "Nothing to format." | 2746 print "Nothing to format." |
2747 return 0 | 2747 return 0 |
2748 cmd = [clang_format_tool] | 2748 cmd = [clang_format_tool] |
2749 if not opts.dry_run and not opts.diff: | 2749 if not opts.dry_run and not opts.diff: |
2750 cmd.append('-i') | 2750 cmd.append('-i') |
2751 stdout = RunCommand(cmd + files, cwd=top_dir) | 2751 stdout = RunCommand(cmd + files, cwd=top_dir) |
2752 if opts.diff: | 2752 if opts.diff: |
2753 sys.stdout.write(stdout) | 2753 sys.stdout.write(stdout) |
2754 else: | 2754 else: |
2755 env = os.environ.copy() | 2755 env = os.environ.copy() |
2756 env['PATH'] = os.path.dirname(clang_format_tool) | 2756 env['PATH'] = str(os.path.dirname(clang_format_tool)) |
2757 # diff_output is a patch to send to clang-format-diff.py | 2757 # diff_output is a patch to send to clang-format-diff.py |
2758 try: | 2758 try: |
2759 script = clang_format.FindClangFormatScriptInChromiumTree( | 2759 script = clang_format.FindClangFormatScriptInChromiumTree( |
2760 'clang-format-diff.py') | 2760 'clang-format-diff.py') |
2761 except clang_format.NotFoundError, e: | 2761 except clang_format.NotFoundError, e: |
2762 DieWithError(e) | 2762 DieWithError(e) |
2763 | 2763 |
2764 cmd = [sys.executable, script, '-p0'] | 2764 cmd = [sys.executable, script, '-p0'] |
2765 if not opts.dry_run and not opts.diff: | 2765 if not opts.dry_run and not opts.diff: |
2766 cmd.append('-i') | 2766 cmd.append('-i') |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2812 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2813 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2813 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2814 | 2814 |
2815 | 2815 |
2816 if __name__ == '__main__': | 2816 if __name__ == '__main__': |
2817 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2817 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2818 # unit testing. | 2818 # unit testing. |
2819 fix_encoding.fix_encoding() | 2819 fix_encoding.fix_encoding() |
2820 colorama.init() | 2820 colorama.init() |
2821 sys.exit(main(sys.argv[1:])) | 2821 sys.exit(main(sys.argv[1:])) |
OLD | NEW |