| 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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 # We use the sha1 of HEAD as a name of this change. | 1368 # We use the sha1 of HEAD as a name of this change. |
| 1369 name = RunGitWithCode(['rev-parse', 'HEAD'])[1].strip() | 1369 name = RunGitWithCode(['rev-parse', 'HEAD'])[1].strip() |
| 1370 # Need to pass a relative path for msysgit. | 1370 # Need to pass a relative path for msysgit. |
| 1371 try: | 1371 try: |
| 1372 files = scm.GIT.CaptureStatus([root], '.', upstream_branch) | 1372 files = scm.GIT.CaptureStatus([root], '.', upstream_branch) |
| 1373 except subprocess2.CalledProcessError: | 1373 except subprocess2.CalledProcessError: |
| 1374 DieWithError( | 1374 DieWithError( |
| 1375 ('\nFailed to diff against upstream branch %s\n\n' | 1375 ('\nFailed to diff against upstream branch %s\n\n' |
| 1376 'This branch probably doesn\'t exist anymore. To reset the\n' | 1376 'This branch probably doesn\'t exist anymore. To reset the\n' |
| 1377 'tracking branch, please run\n' | 1377 'tracking branch, please run\n' |
| 1378 ' git branch --set-upstream %s trunk\n' | 1378 ' git branch --set-upstream-to origin/master %s\n' |
| 1379 'replacing trunk with origin/master or the relevant branch') % | 1379 'or replace origin/master with the relevant branch') % |
| 1380 (upstream_branch, self.GetBranch())) | 1380 (upstream_branch, self.GetBranch())) |
| 1381 | 1381 |
| 1382 issue = self.GetIssue() | 1382 issue = self.GetIssue() |
| 1383 patchset = self.GetPatchset() | 1383 patchset = self.GetPatchset() |
| 1384 if issue and not local_description: | 1384 if issue and not local_description: |
| 1385 description = self.GetDescription() | 1385 description = self.GetDescription() |
| 1386 else: | 1386 else: |
| 1387 # If the change was never uploaded, use the log messages of all commits | 1387 # If the change was never uploaded, use the log messages of all commits |
| 1388 # up to the branch point, as git cl upload will prefill the description | 1388 # up to the branch point, as git cl upload will prefill the description |
| 1389 # with these log messages. | 1389 # with these log messages. |
| (...skipping 3472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4862 def CMDupstream(parser, args): | 4862 def CMDupstream(parser, args): |
| 4863 """Prints or sets the name of the upstream branch, if any.""" | 4863 """Prints or sets the name of the upstream branch, if any.""" |
| 4864 _, args = parser.parse_args(args) | 4864 _, args = parser.parse_args(args) |
| 4865 if len(args) > 1: | 4865 if len(args) > 1: |
| 4866 parser.error('Unrecognized args: %s' % ' '.join(args)) | 4866 parser.error('Unrecognized args: %s' % ' '.join(args)) |
| 4867 | 4867 |
| 4868 cl = Changelist() | 4868 cl = Changelist() |
| 4869 if args: | 4869 if args: |
| 4870 # One arg means set upstream branch. | 4870 # One arg means set upstream branch. |
| 4871 branch = cl.GetBranch() | 4871 branch = cl.GetBranch() |
| 4872 RunGit(['branch', '--set-upstream', branch, args[0]]) | 4872 RunGit(['branch', '--set-upstream-to', args[0], branch]) |
| 4873 cl = Changelist() | 4873 cl = Changelist() |
| 4874 print('Upstream branch set to %s' % (cl.GetUpstreamBranch(),)) | 4874 print('Upstream branch set to %s' % (cl.GetUpstreamBranch(),)) |
| 4875 | 4875 |
| 4876 # Clear configured merge-base, if there is one. | 4876 # Clear configured merge-base, if there is one. |
| 4877 git_common.remove_merge_base(branch) | 4877 git_common.remove_merge_base(branch) |
| 4878 else: | 4878 else: |
| 4879 print(cl.GetUpstreamBranch()) | 4879 print(cl.GetUpstreamBranch()) |
| 4880 return 0 | 4880 return 0 |
| 4881 | 4881 |
| 4882 | 4882 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5296 if __name__ == '__main__': | 5296 if __name__ == '__main__': |
| 5297 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5297 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5298 # unit testing. | 5298 # unit testing. |
| 5299 fix_encoding.fix_encoding() | 5299 fix_encoding.fix_encoding() |
| 5300 setup_color.init() | 5300 setup_color.init() |
| 5301 try: | 5301 try: |
| 5302 sys.exit(main(sys.argv[1:])) | 5302 sys.exit(main(sys.argv[1:])) |
| 5303 except KeyboardInterrupt: | 5303 except KeyboardInterrupt: |
| 5304 sys.stderr.write('interrupted\n') | 5304 sys.stderr.write('interrupted\n') |
| 5305 sys.exit(1) | 5305 sys.exit(1) |
| OLD | NEW |