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 # Wrapper script around Rietveld's upload.py that groups files into | 6 # Wrapper script around Rietveld's upload.py that groups files into |
7 # changelists. | 7 # changelists. |
8 | 8 |
9 import getpass | 9 import getpass |
10 import os | 10 import os |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 # The file is not modified anymore. It should be removed from the set. | 721 # The file is not modified anymore. It should be removed from the set. |
722 pass | 722 pass |
723 os.chdir(previous_cwd) | 723 os.chdir(previous_cwd) |
724 return "".join(diff) | 724 return "".join(diff) |
725 | 725 |
726 | 726 |
727 | 727 |
728 def OptionallyDoPresubmitChecks(change_info, committing, args): | 728 def OptionallyDoPresubmitChecks(change_info, committing, args): |
729 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"): | 729 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"): |
730 return True | 730 return True |
731 return DoPresubmitChecks(change_info, committing=committing) | 731 return DoPresubmitChecks(change_info, committing, True) |
732 | 732 |
733 | 733 |
734 def UploadCL(change_info, args): | 734 def UploadCL(change_info, args): |
735 if not change_info.FileList(): | 735 if not change_info.FileList(): |
736 print "Nothing to upload, changelist is empty." | 736 print "Nothing to upload, changelist is empty." |
737 return | 737 return |
738 if not OptionallyDoPresubmitChecks(change_info, False, args): | 738 if not OptionallyDoPresubmitChecks(change_info, False, args): |
739 return | 739 return |
740 no_try = FilterFlag(args, "--no_try") or FilterFlag(args, "--no-try") | 740 no_try = FilterFlag(args, "--no_try") or FilterFlag(args, "--no-try") |
741 | 741 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 os.chdir(previous_cwd) | 824 os.chdir(previous_cwd) |
825 | 825 |
826 | 826 |
827 def PresubmitCL(change_info): | 827 def PresubmitCL(change_info): |
828 """Reports what presubmit checks on the change would report.""" | 828 """Reports what presubmit checks on the change would report.""" |
829 if not change_info.FileList(): | 829 if not change_info.FileList(): |
830 print "Nothing to presubmit check, changelist is empty." | 830 print "Nothing to presubmit check, changelist is empty." |
831 return | 831 return |
832 | 832 |
833 print "*** Presubmit checks for UPLOAD would report: ***" | 833 print "*** Presubmit checks for UPLOAD would report: ***" |
834 DoPresubmitChecks(change_info, committing=False) | 834 DoPresubmitChecks(change_info, False, False) |
835 | 835 |
836 print "\n\n*** Presubmit checks for COMMIT would report: ***" | 836 print "\n*** Presubmit checks for COMMIT would report: ***" |
837 DoPresubmitChecks(change_info, committing=True) | 837 DoPresubmitChecks(change_info, True, False) |
838 | 838 |
839 | 839 |
840 def TryChange(change_info, args, swallow_exception): | 840 def TryChange(change_info, args, swallow_exception): |
841 """Create a diff file of change_info and send it to the try server.""" | 841 """Create a diff file of change_info and send it to the try server.""" |
842 try: | 842 try: |
843 import trychange | 843 import trychange |
844 except ImportError: | 844 except ImportError: |
845 if swallow_exception: | 845 if swallow_exception: |
846 return | 846 return |
847 ErrorExit("You need to install trychange.py to use the try server.") | 847 ErrorExit("You need to install trychange.py to use the try server.") |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 if len([file for suffix in CPP_EXTENSIONS if file.endswith(suffix)]): | 1021 if len([file for suffix in CPP_EXTENSIONS if file.endswith(suffix)]): |
1022 if len([file for prefix in IGNORE_PATHS if file.startswith(prefix)]): | 1022 if len([file for prefix in IGNORE_PATHS if file.startswith(prefix)]): |
1023 print "Ignoring non-Google styled file %s" % file | 1023 print "Ignoring non-Google styled file %s" % file |
1024 else: | 1024 else: |
1025 cpplint.ProcessFile(file, cpplint._cpplint_state.verbose_level) | 1025 cpplint.ProcessFile(file, cpplint._cpplint_state.verbose_level) |
1026 | 1026 |
1027 print "Total errors found: %d\n" % cpplint._cpplint_state.error_count | 1027 print "Total errors found: %d\n" % cpplint._cpplint_state.error_count |
1028 os.chdir(previous_cwd) | 1028 os.chdir(previous_cwd) |
1029 | 1029 |
1030 | 1030 |
1031 def DoPresubmitChecks(change_info, committing): | 1031 def DoPresubmitChecks(change_info, committing, may_prompt): |
1032 """Imports presubmit, then calls presubmit.DoPresubmitChecks.""" | 1032 """Imports presubmit, then calls presubmit.DoPresubmitChecks.""" |
1033 # Need to import here to avoid circular dependency. | 1033 # Need to import here to avoid circular dependency. |
1034 import presubmit_support | 1034 import presubmit_support |
1035 root_presubmit = GetCachedFile('PRESUBMIT.py', use_root=True) | 1035 root_presubmit = GetCachedFile('PRESUBMIT.py', use_root=True) |
1036 result = presubmit_support.DoPresubmitChecks(change_info, | 1036 result = presubmit_support.DoPresubmitChecks(change_info=change_info, |
1037 committing, | 1037 committing=committing, |
1038 verbose=False, | 1038 verbose=False, |
1039 output_stream=sys.stdout, | 1039 output_stream=sys.stdout, |
1040 input_stream=sys.stdin, | 1040 input_stream=sys.stdin, |
1041 default_presubmit=root_presubmit) | 1041 default_presubmit=root_presubmit, |
| 1042 may_prompt=may_prompt) |
1042 if not result: | 1043 if not result: |
1043 print "\nPresubmit errors, can't continue (use --no_presubmit to bypass)" | 1044 print "\nPresubmit errors, can't continue (use --no_presubmit to bypass)" |
1044 return result | 1045 return result |
1045 | 1046 |
1046 | 1047 |
1047 def Changes(): | 1048 def Changes(): |
1048 """Print all the changelists and their files.""" | 1049 """Print all the changelists and their files.""" |
1049 for cl in GetCLs(): | 1050 for cl in GetCLs(): |
1050 change_info = ChangeInfo.Load(cl, True, True) | 1051 change_info = ChangeInfo.Load(cl, True, True) |
1051 print "\n--- Changelist " + change_info.name + ":" | 1052 print "\n--- Changelist " + change_info.name + ":" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 # the files. This allows commands such as 'gcl diff xxx' to work. | 1157 # the files. This allows commands such as 'gcl diff xxx' to work. |
1157 args =["svn", command] | 1158 args =["svn", command] |
1158 root = GetRepositoryRoot() | 1159 root = GetRepositoryRoot() |
1159 args.extend([os.path.join(root, x) for x in change_info.FileList()]) | 1160 args.extend([os.path.join(root, x) for x in change_info.FileList()]) |
1160 RunShell(args, True) | 1161 RunShell(args, True) |
1161 return 0 | 1162 return 0 |
1162 | 1163 |
1163 | 1164 |
1164 if __name__ == "__main__": | 1165 if __name__ == "__main__": |
1165 sys.exit(main()) | 1166 sys.exit(main()) |
OLD | NEW |