| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 14 matching lines...) Expand all Loading... |
| 25 __pychecker__ = '' | 25 __pychecker__ = '' |
| 26 | 26 |
| 27 # gcl now depends on gclient. | 27 # gcl now depends on gclient. |
| 28 from scm import SVN | 28 from scm import SVN |
| 29 import gclient_utils | 29 import gclient_utils |
| 30 | 30 |
| 31 __version__ = '1.2' | 31 __version__ = '1.2' |
| 32 | 32 |
| 33 | 33 |
| 34 CODEREVIEW_SETTINGS = { | 34 CODEREVIEW_SETTINGS = { |
| 35 # Ideally, we want to set |CODE_REVIEW_SERVER| to a generic server like | 35 # To make gcl send reviews to a server, check in a file named |
| 36 # codereview.appspot.com and remove |CC_LIST| and |VIEW_VC|. In practice, we | |
| 37 # need these settings so developers making changes in directories such as | |
| 38 # Chromium's src/third_party/WebKit will send change lists to the correct | |
| 39 # server. | |
| 40 # | |
| 41 # To make gcl send reviews to a different server, check in a file named | |
| 42 # "codereview.settings" (see |CODEREVIEW_SETTINGS_FILE| below) to your | 36 # "codereview.settings" (see |CODEREVIEW_SETTINGS_FILE| below) to your |
| 43 # project's base directory and add the following line to codereview.settings: | 37 # project's base directory and add the following line to codereview.settings: |
| 44 # CODE_REVIEW_SERVER: codereview.yourserver.org | 38 # CODE_REVIEW_SERVER: codereview.yourserver.org |
| 45 # | |
| 46 # Default values. | |
| 47 "CODE_REVIEW_SERVER": "codereview.chromium.org", | |
| 48 "CC_LIST": "chromium-reviews@chromium.org", | |
| 49 "VIEW_VC": "http://src.chromium.org/viewvc/chrome?view=rev&revision=", | |
| 50 } | 39 } |
| 51 | 40 |
| 52 # globals that store the root of the current repository and the directory where | 41 # globals that store the root of the current repository and the directory where |
| 53 # we store information about changelists. | 42 # we store information about changelists. |
| 54 REPOSITORY_ROOT = "" | 43 REPOSITORY_ROOT = "" |
| 55 | 44 |
| 56 # Filename where we store repository specific information for gcl. | 45 # Filename where we store repository specific information for gcl. |
| 57 CODEREVIEW_SETTINGS_FILE = "codereview.settings" | 46 CODEREVIEW_SETTINGS_FILE = "codereview.settings" |
| 47 CODEREVIEW_SETTINGS_FILE_NOT_FOUND = ( |
| 48 'No %s file found. Please add one.' % CODEREVIEW_SETTINGS_FILE) |
| 58 | 49 |
| 59 # Warning message when the change appears to be missing tests. | 50 # Warning message when the change appears to be missing tests. |
| 60 MISSING_TEST_MSG = "Change contains new or modified methods, but no new tests!" | 51 MISSING_TEST_MSG = "Change contains new or modified methods, but no new tests!" |
| 61 | 52 |
| 62 # Global cache of files cached in GetCacheDir(). | 53 # Global cache of files cached in GetCacheDir(). |
| 63 FILES_CACHE = {} | 54 FILES_CACHE = {} |
| 64 | 55 |
| 65 # Valid extensions for files we want to lint. | 56 # Valid extensions for files we want to lint. |
| 66 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" | 57 DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)" |
| 67 DEFAULT_LINT_IGNORE_REGEX = r"$^" | 58 DEFAULT_LINT_IGNORE_REGEX = r"$^" |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 modified_files = GetModifiedFiles() | 554 modified_files = GetModifiedFiles() |
| 564 if "" not in modified_files: | 555 if "" not in modified_files: |
| 565 return [] | 556 return [] |
| 566 return modified_files[""] | 557 return modified_files[""] |
| 567 | 558 |
| 568 | 559 |
| 569 def SendToRietveld(request_path, payload=None, | 560 def SendToRietveld(request_path, payload=None, |
| 570 content_type="application/octet-stream", timeout=None): | 561 content_type="application/octet-stream", timeout=None): |
| 571 """Send a POST/GET to Rietveld. Returns the response body.""" | 562 """Send a POST/GET to Rietveld. Returns the response body.""" |
| 572 server = GetCodeReviewSetting("CODE_REVIEW_SERVER") | 563 server = GetCodeReviewSetting("CODE_REVIEW_SERVER") |
| 564 if not server: |
| 565 ErrorExit(CODEREVIEW_SETTINGS_FILE_NOT_FOUND) |
| 573 def GetUserCredentials(): | 566 def GetUserCredentials(): |
| 574 """Prompts the user for a username and password.""" | 567 """Prompts the user for a username and password.""" |
| 575 email = upload.GetEmail("Email (login for uploading to %s)" % server) | 568 email = upload.GetEmail("Email (login for uploading to %s)" % server) |
| 576 password = getpass.getpass("Password for %s: " % email) | 569 password = getpass.getpass("Password for %s: " % email) |
| 577 return email, password | 570 return email, password |
| 578 rpc_server = upload.HttpRpcServer(server, | 571 rpc_server = upload.HttpRpcServer(server, |
| 579 GetUserCredentials, | 572 GetUserCredentials, |
| 580 save_cookies=True) | 573 save_cookies=True) |
| 581 try: | 574 try: |
| 582 return rpc_server.Send(request_path, payload, content_type, timeout) | 575 return rpc_server.Send(request_path, payload, content_type, timeout) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 FilterFlag(args, "--no-watchlists")) | 716 FilterFlag(args, "--no-watchlists")) |
| 724 | 717 |
| 725 # Map --send-mail to --send_mail | 718 # Map --send-mail to --send_mail |
| 726 if FilterFlag(args, "--send-mail"): | 719 if FilterFlag(args, "--send-mail"): |
| 727 args.append("--send_mail") | 720 args.append("--send_mail") |
| 728 | 721 |
| 729 # Supports --clobber for the try server. | 722 # Supports --clobber for the try server. |
| 730 clobber = FilterFlag(args, "--clobber") | 723 clobber = FilterFlag(args, "--clobber") |
| 731 | 724 |
| 732 upload_arg = ["upload.py", "-y"] | 725 upload_arg = ["upload.py", "-y"] |
| 733 upload_arg.append("--server=" + GetCodeReviewSetting("CODE_REVIEW_SERVER")) | 726 server = GetCodeReviewSetting("CODE_REVIEW_SERVER") |
| 727 if not server: |
| 728 ErrorExit(CODEREVIEW_SETTINGS_FILE_NOT_FOUND) |
| 729 upload_arg.append("--server=%s" % server) |
| 734 upload_arg.extend(args) | 730 upload_arg.extend(args) |
| 735 | 731 |
| 736 desc_file = "" | 732 desc_file = "" |
| 737 if change_info.issue: # Uploading a new patchset. | 733 if change_info.issue: # Uploading a new patchset. |
| 738 found_message = False | 734 found_message = False |
| 739 for arg in args: | 735 for arg in args: |
| 740 if arg.startswith("--message") or arg.startswith("-m"): | 736 if arg.startswith("--message") or arg.startswith("-m"): |
| 741 found_message = True | 737 found_message = True |
| 742 break | 738 break |
| 743 | 739 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 # you'll get "svn: Cannot non-recursively commit a directory deletion of a | 871 # you'll get "svn: Cannot non-recursively commit a directory deletion of a |
| 876 # directory with child nodes". Yay... | 872 # directory with child nodes". Yay... |
| 877 commit_cmd = ["svn", "commit"] | 873 commit_cmd = ["svn", "commit"] |
| 878 if change_info.issue: | 874 if change_info.issue: |
| 879 # Get the latest description from Rietveld. | 875 # Get the latest description from Rietveld. |
| 880 change_info.description = GetIssueDescription(change_info.issue) | 876 change_info.description = GetIssueDescription(change_info.issue) |
| 881 | 877 |
| 882 commit_message = change_info.description.replace('\r\n', '\n') | 878 commit_message = change_info.description.replace('\r\n', '\n') |
| 883 if change_info.issue: | 879 if change_info.issue: |
| 884 server = GetCodeReviewSetting("CODE_REVIEW_SERVER") | 880 server = GetCodeReviewSetting("CODE_REVIEW_SERVER") |
| 881 if not server: |
| 882 ErrorExit(CODEREVIEW_SETTINGS_FILE_NOT_FOUND) |
| 885 if not server.startswith("http://") and not server.startswith("https://"): | 883 if not server.startswith("http://") and not server.startswith("https://"): |
| 886 server = "http://" + server | 884 server = "http://" + server |
| 887 commit_message += ('\nReview URL: %s/%d' % (server, change_info.issue)) | 885 commit_message += ('\nReview URL: %s/%d' % (server, change_info.issue)) |
| 888 | 886 |
| 889 handle, commit_filename = tempfile.mkstemp(text=True) | 887 handle, commit_filename = tempfile.mkstemp(text=True) |
| 890 os.write(handle, commit_message) | 888 os.write(handle, commit_message) |
| 891 os.close(handle) | 889 os.close(handle) |
| 892 | 890 |
| 893 handle, targets_filename = tempfile.mkstemp(text=True) | 891 handle, targets_filename = tempfile.mkstemp(text=True) |
| 894 os.write(handle, "\n".join(change_info.GetFileNames())) | 892 os.write(handle, "\n".join(change_info.GetFileNames())) |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 if command: | 1299 if command: |
| 1302 return command(argv[1:]) | 1300 return command(argv[1:]) |
| 1303 # Unknown command, try to pass that to svn | 1301 # Unknown command, try to pass that to svn |
| 1304 return CMDpassthru(argv) | 1302 return CMDpassthru(argv) |
| 1305 except gclient_utils.Error, e: | 1303 except gclient_utils.Error, e: |
| 1306 print('Got an exception') | 1304 print('Got an exception') |
| 1307 print(str(e)) | 1305 print(str(e)) |
| 1308 | 1306 |
| 1309 if __name__ == "__main__": | 1307 if __name__ == "__main__": |
| 1310 sys.exit(main(sys.argv[1:])) | 1308 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |