OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """\ | 6 """\ |
7 Wrapper script around Rietveld's upload.py that simplifies working with groups | 7 Wrapper script around Rietveld's upload.py that simplifies working with groups |
8 of files. | 8 of files. |
9 """ | 9 """ |
10 | 10 |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 commit_message = change_info.description.replace('\r\n', '\n') | 993 commit_message = change_info.description.replace('\r\n', '\n') |
994 if change_info.issue: | 994 if change_info.issue: |
995 server = change_info.rietveld | 995 server = change_info.rietveld |
996 if not server.startswith("http://") and not server.startswith("https://"): | 996 if not server.startswith("http://") and not server.startswith("https://"): |
997 server = "http://" + server | 997 server = "http://" + server |
998 commit_message += ('\nReview URL: %s/%d' % (server, change_info.issue)) | 998 commit_message += ('\nReview URL: %s/%d' % (server, change_info.issue)) |
999 | 999 |
1000 handle, commit_filename = tempfile.mkstemp(text=True) | 1000 handle, commit_filename = tempfile.mkstemp(text=True) |
1001 os.write(handle, commit_message) | 1001 os.write(handle, commit_message) |
1002 os.close(handle) | 1002 os.close(handle) |
1003 | 1003 try: |
1004 handle, targets_filename = tempfile.mkstemp(text=True) | 1004 handle, targets_filename = tempfile.mkstemp(text=True) |
1005 os.write(handle, "\n".join(change_info.GetFileNames())) | 1005 os.write(handle, "\n".join(change_info.GetFileNames())) |
1006 os.close(handle) | 1006 os.close(handle) |
1007 | 1007 try: |
1008 commit_cmd += ['--file=' + commit_filename] | 1008 commit_cmd += ['--file=' + commit_filename] |
1009 commit_cmd += ['--targets=' + targets_filename] | 1009 commit_cmd += ['--targets=' + targets_filename] |
1010 # Change the current working directory before calling commit. | 1010 # Change the current working directory before calling commit. |
1011 previous_cwd = os.getcwd() | 1011 previous_cwd = os.getcwd() |
1012 os.chdir(change_info.GetLocalRoot()) | 1012 os.chdir(change_info.GetLocalRoot()) |
1013 output = RunShell(commit_cmd, True) | 1013 output = '' |
1014 os.remove(commit_filename) | 1014 try: |
1015 os.remove(targets_filename) | 1015 output = RunShell(commit_cmd, True) |
| 1016 except subprocess2.CalledProcessError, e: |
| 1017 ErrorExit('Commit failed.\n%s' % e) |
| 1018 finally: |
| 1019 os.remove(commit_filename) |
| 1020 finally: |
| 1021 os.remove(targets_filename) |
1016 if output.find("Committed revision") != -1: | 1022 if output.find("Committed revision") != -1: |
1017 change_info.Delete() | 1023 change_info.Delete() |
1018 | 1024 |
1019 if change_info.issue: | 1025 if change_info.issue: |
1020 revision = re.compile(".*?\nCommitted revision (\d+)", | 1026 revision = re.compile(".*?\nCommitted revision (\d+)", |
1021 re.DOTALL).match(output).group(1) | 1027 re.DOTALL).match(output).group(1) |
1022 viewvc_url = GetCodeReviewSetting("VIEW_VC") | 1028 viewvc_url = GetCodeReviewSetting("VIEW_VC") |
1023 change_info.description += '\n' | 1029 change_info.description += '\n' |
1024 if viewvc_url: | 1030 if viewvc_url: |
1025 change_info.description += "\nCommitted: " + viewvc_url + revision | 1031 change_info.description += "\nCommitted: " + viewvc_url + revision |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 raise | 1444 raise |
1439 print >> sys.stderr, ( | 1445 print >> sys.stderr, ( |
1440 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1446 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
1441 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 1447 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) |
1442 return 1 | 1448 return 1 |
1443 | 1449 |
1444 | 1450 |
1445 if __name__ == "__main__": | 1451 if __name__ == "__main__": |
1446 fix_encoding.fix_encoding() | 1452 fix_encoding.fix_encoding() |
1447 sys.exit(main(sys.argv[1:])) | 1453 sys.exit(main(sys.argv[1:])) |
OLD | NEW |