| 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 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2890 if args: | 2890 if args: |
| 2891 parser.error('Unrecognized args: %s' % ' '.join(args)) | 2891 parser.error('Unrecognized args: %s' % ' '.join(args)) |
| 2892 cl = Changelist() | 2892 cl = Changelist() |
| 2893 # Ensure there actually is an issue to close. | 2893 # Ensure there actually is an issue to close. |
| 2894 cl.GetDescription() | 2894 cl.GetDescription() |
| 2895 cl.CloseIssue() | 2895 cl.CloseIssue() |
| 2896 return 0 | 2896 return 0 |
| 2897 | 2897 |
| 2898 | 2898 |
| 2899 def CMDdiff(parser, args): | 2899 def CMDdiff(parser, args): |
| 2900 """shows differences between local tree and last upload.""" | 2900 """Shows differences between local tree and last upload.""" |
| 2901 parser.parse_args(args) | 2901 parser.parse_args(args) |
| 2902 cl = Changelist() | 2902 cl = Changelist() |
| 2903 issue = cl.GetIssue() | 2903 issue = cl.GetIssue() |
| 2904 branch = cl.GetBranch() | 2904 branch = cl.GetBranch() |
| 2905 if not issue: | 2905 if not issue: |
| 2906 DieWithError('No issue found for current branch (%s)' % branch) | 2906 DieWithError('No issue found for current branch (%s)' % branch) |
| 2907 TMP_BRANCH = 'git-cl-diff' | 2907 TMP_BRANCH = 'git-cl-diff' |
| 2908 base_branch = cl.GetCommonAncestorWithUpstream() | 2908 base_branch = cl.GetCommonAncestorWithUpstream() |
| 2909 | 2909 |
| 2910 # Create a new branch based on the merge-base | 2910 # Create a new branch based on the merge-base |
| 2911 RunGit(['checkout', '-q', '-b', TMP_BRANCH, base_branch]) | 2911 RunGit(['checkout', '-q', '-b', TMP_BRANCH, base_branch]) |
| 2912 try: | 2912 try: |
| 2913 # Patch in the latest changes from rietveld. | 2913 # Patch in the latest changes from rietveld. |
| 2914 rtn = PatchIssue(issue, False, False, None) | 2914 rtn = PatchIssue(issue, False, False, None) |
| 2915 if rtn != 0: | 2915 if rtn != 0: |
| 2916 return rtn | 2916 return rtn |
| 2917 | 2917 |
| 2918 # Switch back to starting branch and diff against the temporary | 2918 # Switch back to starting branch and diff against the temporary |
| 2919 # branch containing the latest rietveld patch. | 2919 # branch containing the latest rietveld patch. |
| 2920 subprocess2.check_call(['git', 'diff', TMP_BRANCH, branch, '--']) | 2920 subprocess2.check_call(['git', 'diff', TMP_BRANCH, branch, '--']) |
| 2921 finally: | 2921 finally: |
| 2922 RunGit(['checkout', '-q', branch]) | 2922 RunGit(['checkout', '-q', branch]) |
| 2923 RunGit(['branch', '-D', TMP_BRANCH]) | 2923 RunGit(['branch', '-D', TMP_BRANCH]) |
| 2924 | 2924 |
| 2925 return 0 | 2925 return 0 |
| 2926 | 2926 |
| 2927 | 2927 |
| 2928 def CMDowners(parser, args): | 2928 def CMDowners(parser, args): |
| 2929 """interactively find the owners for reviewing""" | 2929 """Interactively find the owners for reviewing.""" |
| 2930 parser.add_option( | 2930 parser.add_option( |
| 2931 '--no-color', | 2931 '--no-color', |
| 2932 action='store_true', | 2932 action='store_true', |
| 2933 help='Use this option to disable color output') | 2933 help='Use this option to disable color output') |
| 2934 options, args = parser.parse_args(args) | 2934 options, args = parser.parse_args(args) |
| 2935 | 2935 |
| 2936 author = RunGit(['config', 'user.email']).strip() or None | 2936 author = RunGit(['config', 'user.email']).strip() or None |
| 2937 | 2937 |
| 2938 cl = Changelist() | 2938 cl = Changelist() |
| 2939 | 2939 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 if __name__ == '__main__': | 3136 if __name__ == '__main__': |
| 3137 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3137 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 3138 # unit testing. | 3138 # unit testing. |
| 3139 fix_encoding.fix_encoding() | 3139 fix_encoding.fix_encoding() |
| 3140 colorama.init() | 3140 colorama.init() |
| 3141 try: | 3141 try: |
| 3142 sys.exit(main(sys.argv[1:])) | 3142 sys.exit(main(sys.argv[1:])) |
| 3143 except KeyboardInterrupt: | 3143 except KeyboardInterrupt: |
| 3144 sys.stderr.write('interrupted\n') | 3144 sys.stderr.write('interrupted\n') |
| 3145 sys.exit(1) | 3145 sys.exit(1) |
| OLD | NEW |