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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 return ListFiles(False) | 701 return ListFiles(False) |
702 | 702 |
703 | 703 |
704 @no_args | 704 @no_args |
705 def CMDstatus(): | 705 def CMDstatus(): |
706 """Lists modified and unknown files in the current directory down.""" | 706 """Lists modified and unknown files in the current directory down.""" |
707 return ListFiles(True) | 707 return ListFiles(True) |
708 | 708 |
709 | 709 |
710 @need_change_and_args | 710 @need_change_and_args |
711 @attrs(usage='[--no_try] [--no_presubmit] [--clobber]\n' | 711 @attrs(usage='[--no_presubmit] [--clobber] [--no_watchlists]') |
712 ' [--no_watchlists]') | |
713 def CMDupload(change_info, args): | 712 def CMDupload(change_info, args): |
714 """Uploads the changelist to the server for review. | 713 """Uploads the changelist to the server for review. |
715 | 714 |
716 (You can create the file '.gcl_upload_no_try' in your home dir to | 715 This does not submit a try job; use gcl try to submit a try job. |
717 skip the automatic tries.) | |
718 """ | 716 """ |
719 if not change_info.GetFiles(): | 717 if not change_info.GetFiles(): |
720 print "Nothing to upload, changelist is empty." | 718 print "Nothing to upload, changelist is empty." |
721 return 0 | 719 return 0 |
722 if not OptionallyDoPresubmitChecks(change_info, False, args): | 720 if not OptionallyDoPresubmitChecks(change_info, False, args): |
723 return 1 | 721 return 1 |
724 # Might want to support GetInfoDir()/GetRepositoryRoot() like | |
725 # CheckHomeForFile() so the skip of tries can be per tree basis instead | |
726 # of user global. | |
727 no_try = (FilterFlag(args, "--no_try") or | |
728 FilterFlag(args, "--no-try") or | |
729 not (CheckHomeForFile(".gcl_upload_no_try") is None)) | |
730 no_watchlists = (FilterFlag(args, "--no_watchlists") or | 722 no_watchlists = (FilterFlag(args, "--no_watchlists") or |
731 FilterFlag(args, "--no-watchlists")) | 723 FilterFlag(args, "--no-watchlists")) |
732 | 724 |
733 # Map --send-mail to --send_mail | 725 # Map --send-mail to --send_mail |
734 if FilterFlag(args, "--send-mail"): | 726 if FilterFlag(args, "--send-mail"): |
735 args.append("--send_mail") | 727 args.append("--send_mail") |
736 | 728 |
737 # Supports --clobber for the try server. | 729 # Supports --clobber for the try server. |
738 clobber = FilterFlag(args, "--clobber") | 730 clobber = FilterFlag(args, "--clobber") |
739 | 731 |
740 # Disable try when the server is overridden. | |
741 server_1 = re.compile(r"^-s\b.*") | |
742 server_2 = re.compile(r"^--server\b.*") | |
743 for arg in args: | |
744 if server_1.match(arg) or server_2.match(arg): | |
745 no_try = True | |
746 break | |
747 | |
748 upload_arg = ["upload.py", "-y"] | 732 upload_arg = ["upload.py", "-y"] |
749 upload_arg.append("--server=" + GetCodeReviewSetting("CODE_REVIEW_SERVER")) | 733 upload_arg.append("--server=" + GetCodeReviewSetting("CODE_REVIEW_SERVER")) |
750 upload_arg.extend(args) | 734 upload_arg.extend(args) |
751 | 735 |
752 desc_file = "" | 736 desc_file = "" |
753 if change_info.issue: # Uploading a new patchset. | 737 if change_info.issue: # Uploading a new patchset. |
754 found_message = False | 738 found_message = False |
755 for arg in args: | 739 for arg in args: |
756 if arg.startswith("--message") or arg.startswith("-m"): | 740 if arg.startswith("--message") or arg.startswith("-m"): |
757 found_message = True | 741 found_message = True |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 os.remove(desc_file) | 797 os.remove(desc_file) |
814 | 798 |
815 # Do background work on Rietveld to lint the file so that the results are | 799 # Do background work on Rietveld to lint the file so that the results are |
816 # ready when the issue is viewed. | 800 # ready when the issue is viewed. |
817 SendToRietveld("/lint/issue%s_%s" % (issue, patchset), timeout=0.5) | 801 SendToRietveld("/lint/issue%s_%s" % (issue, patchset), timeout=0.5) |
818 | 802 |
819 # Move back before considering try, so GetCodeReviewSettings is | 803 # Move back before considering try, so GetCodeReviewSettings is |
820 # consistent. | 804 # consistent. |
821 os.chdir(previous_cwd) | 805 os.chdir(previous_cwd) |
822 | 806 |
823 # Once uploaded to Rietveld, send it to the try server. | |
824 if not no_try: | |
825 try_on_upload = GetCodeReviewSetting('TRY_ON_UPLOAD') | |
826 if try_on_upload and try_on_upload.lower() == 'true': | |
827 trychange_args = [] | |
828 if clobber: | |
829 trychange_args.append('--clobber') | |
830 return TryChange(change_info, trychange_args, swallow_exception=True) | |
831 return 0 | 807 return 0 |
832 | 808 |
833 | 809 |
834 @need_change | 810 @need_change |
835 def CMDpresubmit(change_info): | 811 def CMDpresubmit(change_info): |
836 """Runs presubmit checks on the change. | 812 """Runs presubmit checks on the change. |
837 | 813 |
838 The actual presubmit code is implemented in presubmit_support.py and looks | 814 The actual presubmit code is implemented in presubmit_support.py and looks |
839 for PRESUBMIT.py files.""" | 815 for PRESUBMIT.py files.""" |
840 if not change_info.GetFiles(): | 816 if not change_info.GetFiles(): |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 if command: | 1299 if command: |
1324 return command(argv[1:]) | 1300 return command(argv[1:]) |
1325 # Unknown command, try to pass that to svn | 1301 # Unknown command, try to pass that to svn |
1326 return CMDpassthru(argv) | 1302 return CMDpassthru(argv) |
1327 except gclient_utils.Error, e: | 1303 except gclient_utils.Error, e: |
1328 print('Got an exception') | 1304 print('Got an exception') |
1329 print(str(e)) | 1305 print(str(e)) |
1330 | 1306 |
1331 if __name__ == "__main__": | 1307 if __name__ == "__main__": |
1332 sys.exit(main(sys.argv[1:])) | 1308 sys.exit(main(sys.argv[1:])) |
OLD | NEW |