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 and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from __future__ import print_function | 10 from __future__ import print_function |
(...skipping 4856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4867 cl = Changelist(auth_config=auth_config, issue=options.issue, | 4867 cl = Changelist(auth_config=auth_config, issue=options.issue, |
4868 codereview=options.forced_codereview) | 4868 codereview=options.forced_codereview) |
4869 # Ensure there actually is an issue to close. | 4869 # Ensure there actually is an issue to close. |
4870 cl.GetDescription() | 4870 cl.GetDescription() |
4871 cl.CloseIssue() | 4871 cl.CloseIssue() |
4872 return 0 | 4872 return 0 |
4873 | 4873 |
4874 | 4874 |
4875 def CMDdiff(parser, args): | 4875 def CMDdiff(parser, args): |
4876 """Shows differences between local tree and last upload.""" | 4876 """Shows differences between local tree and last upload.""" |
| 4877 parser.add_option( |
| 4878 '--stat', |
| 4879 action='store_true', |
| 4880 dest='stat', |
| 4881 help='Generate a diffstat') |
4877 auth.add_auth_options(parser) | 4882 auth.add_auth_options(parser) |
4878 options, args = parser.parse_args(args) | 4883 options, args = parser.parse_args(args) |
4879 auth_config = auth.extract_auth_config_from_options(options) | 4884 auth_config = auth.extract_auth_config_from_options(options) |
4880 if args: | 4885 if args: |
4881 parser.error('Unrecognized args: %s' % ' '.join(args)) | 4886 parser.error('Unrecognized args: %s' % ' '.join(args)) |
4882 | 4887 |
4883 # Uncommitted (staged and unstaged) changes will be destroyed by | 4888 # Uncommitted (staged and unstaged) changes will be destroyed by |
4884 # "git reset --hard" if there are merging conflicts in CMDPatchIssue(). | 4889 # "git reset --hard" if there are merging conflicts in CMDPatchIssue(). |
4885 # Staged changes would be committed along with the patch from last | 4890 # Staged changes would be committed along with the patch from last |
4886 # upload, hence counted toward the "last upload" side in the final | 4891 # upload, hence counted toward the "last upload" side in the final |
(...skipping 15 matching lines...) Expand all Loading... |
4902 # properties. | 4907 # properties. |
4903 cl.ClearBranch() | 4908 cl.ClearBranch() |
4904 try: | 4909 try: |
4905 rtn = cl.CMDPatchIssue(issue, reject=False, nocommit=False, directory=None) | 4910 rtn = cl.CMDPatchIssue(issue, reject=False, nocommit=False, directory=None) |
4906 if rtn != 0: | 4911 if rtn != 0: |
4907 RunGit(['reset', '--hard']) | 4912 RunGit(['reset', '--hard']) |
4908 return rtn | 4913 return rtn |
4909 | 4914 |
4910 # Switch back to starting branch and diff against the temporary | 4915 # Switch back to starting branch and diff against the temporary |
4911 # branch containing the latest rietveld patch. | 4916 # branch containing the latest rietveld patch. |
4912 subprocess2.check_call(['git', 'diff', TMP_BRANCH, branch, '--']) | 4917 cmd = ['git', 'diff'] |
| 4918 if options.stat: |
| 4919 cmd.append('--stat') |
| 4920 cmd.extend([TMP_BRANCH, branch, '--']) |
| 4921 subprocess2.check_call(cmd) |
4913 finally: | 4922 finally: |
4914 RunGit(['checkout', '-q', branch]) | 4923 RunGit(['checkout', '-q', branch]) |
4915 RunGit(['branch', '-D', TMP_BRANCH]) | 4924 RunGit(['branch', '-D', TMP_BRANCH]) |
4916 | 4925 |
4917 return 0 | 4926 return 0 |
4918 | 4927 |
4919 | 4928 |
4920 def CMDowners(parser, args): | 4929 def CMDowners(parser, args): |
4921 """Interactively find the owners for reviewing.""" | 4930 """Interactively find the owners for reviewing.""" |
4922 parser.add_option( | 4931 parser.add_option( |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5217 if __name__ == '__main__': | 5226 if __name__ == '__main__': |
5218 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5227 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5219 # unit testing. | 5228 # unit testing. |
5220 fix_encoding.fix_encoding() | 5229 fix_encoding.fix_encoding() |
5221 setup_color.init() | 5230 setup_color.init() |
5222 try: | 5231 try: |
5223 sys.exit(main(sys.argv[1:])) | 5232 sys.exit(main(sys.argv[1:])) |
5224 except KeyboardInterrupt: | 5233 except KeyboardInterrupt: |
5225 sys.stderr.write('interrupted\n') | 5234 sys.stderr.write('interrupted\n') |
5226 sys.exit(1) | 5235 sys.exit(1) |
OLD | NEW |