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 import json | 10 import json |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 if ': ' in line) | 1012 if ': ' in line) |
1013 remote_url = keys.get('URL', None) | 1013 remote_url = keys.get('URL', None) |
1014 else: | 1014 else: |
1015 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): | 1015 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): |
1016 remote_url = (cl.GetRemoteUrl() + '@' | 1016 remote_url = (cl.GetRemoteUrl() + '@' |
1017 + cl.GetUpstreamBranch().split('/')[-1]) | 1017 + cl.GetUpstreamBranch().split('/')[-1]) |
1018 if remote_url: | 1018 if remote_url: |
1019 upload_args.extend(['--base_url', remote_url]) | 1019 upload_args.extend(['--base_url', remote_url]) |
1020 | 1020 |
1021 try: | 1021 try: |
1022 issue, patchset = upload.RealMain(['upload'] + upload_args + args) | 1022 # upload uses '-C' by default when generating the diff for upload. |
| 1023 # Add another '-C' to trigger --find-copies-harder. |
| 1024 issue, patchset = upload.RealMain(['upload'] + upload_args + args + |
| 1025 ['--', '-C']) |
1023 except KeyboardInterrupt: | 1026 except KeyboardInterrupt: |
1024 sys.exit(1) | 1027 sys.exit(1) |
1025 except: | 1028 except: |
1026 # If we got an exception after the user typed a description for their | 1029 # If we got an exception after the user typed a description for their |
1027 # change, back up the description before re-raising. | 1030 # change, back up the description before re-raising. |
1028 if change_desc: | 1031 if change_desc: |
1029 backup_path = os.path.expanduser(DESCRIPTION_BACKUP_FILE) | 1032 backup_path = os.path.expanduser(DESCRIPTION_BACKUP_FILE) |
1030 print '\nGot exception while uploading -- saving description to %s\n' \ | 1033 print '\nGot exception while uploading -- saving description to %s\n' \ |
1031 % backup_path | 1034 % backup_path |
1032 backup_file = open(backup_path, 'w') | 1035 backup_file = open(backup_path, 'w') |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 if not options.reviewers and hook_results.reviewers: | 1108 if not options.reviewers and hook_results.reviewers: |
1106 options.reviewers = hook_results.reviewers | 1109 options.reviewers = hook_results.reviewers |
1107 | 1110 |
1108 # --no-ext-diff is broken in some versions of Git, so try to work around | 1111 # --no-ext-diff is broken in some versions of Git, so try to work around |
1109 # this by overriding the environment (but there is still a problem if the | 1112 # this by overriding the environment (but there is still a problem if the |
1110 # git config key "diff.external" is used). | 1113 # git config key "diff.external" is used). |
1111 env = os.environ.copy() | 1114 env = os.environ.copy() |
1112 if 'GIT_EXTERNAL_DIFF' in env: | 1115 if 'GIT_EXTERNAL_DIFF' in env: |
1113 del env['GIT_EXTERNAL_DIFF'] | 1116 del env['GIT_EXTERNAL_DIFF'] |
1114 subprocess2.call( | 1117 subprocess2.call( |
1115 ['git', 'diff', '--no-ext-diff', '--stat', '-M'] + args, env=env) | 1118 ['git', 'diff', '--no-ext-diff', '--stat', '-C', '-C'] + args, env=env) |
1116 | 1119 |
1117 if settings.GetIsGerrit(): | 1120 if settings.GetIsGerrit(): |
1118 return GerritUpload(options, args, cl) | 1121 return GerritUpload(options, args, cl) |
1119 return RietveldUpload(options, args, cl) | 1122 return RietveldUpload(options, args, cl) |
1120 | 1123 |
1121 | 1124 |
1122 def SendUpstream(parser, args, cmd): | 1125 def SendUpstream(parser, args, cmd): |
1123 """Common code for CmdPush and CmdDCommit | 1126 """Common code for CmdPush and CmdDCommit |
1124 | 1127 |
1125 Squashed commit into a single. | 1128 Squashed commit into a single. |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1554 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1552 | 1555 |
1553 # Not a known command. Default to help. | 1556 # Not a known command. Default to help. |
1554 GenUsage(parser, 'help') | 1557 GenUsage(parser, 'help') |
1555 return CMDhelp(parser, argv) | 1558 return CMDhelp(parser, argv) |
1556 | 1559 |
1557 | 1560 |
1558 if __name__ == '__main__': | 1561 if __name__ == '__main__': |
1559 fix_encoding.fix_encoding() | 1562 fix_encoding.fix_encoding() |
1560 sys.exit(main(sys.argv[1:])) | 1563 sys.exit(main(sys.argv[1:])) |
OLD | NEW |