| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Wrapper script around Rietveld's upload.py that groups files into | 2 # Wrapper script around Rietveld's upload.py that groups files into |
| 3 # changelists. | 3 # changelists. |
| 4 | 4 |
| 5 import getpass | 5 import getpass |
| 6 import linecache | 6 import linecache |
| 7 import os | 7 import os |
| 8 import random | 8 import random |
| 9 import re | 9 import re |
| 10 import string | 10 import string |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 721 |
| 722 change_info.Save() | 722 change_info.Save() |
| 723 print change_info.name + " changelist saved." | 723 print change_info.name + " changelist saved." |
| 724 | 724 |
| 725 # We don't lint files in these path prefixes. | 725 # We don't lint files in these path prefixes. |
| 726 IGNORE_PATHS = ("webkit",) | 726 IGNORE_PATHS = ("webkit",) |
| 727 | 727 |
| 728 # Valid extensions for files we want to lint. | 728 # Valid extensions for files we want to lint. |
| 729 CPP_EXTENSIONS = ("cpp", "cc", "h") | 729 CPP_EXTENSIONS = ("cpp", "cc", "h") |
| 730 | 730 |
| 731 def Lint(change_info): | 731 def Lint(change_info, args): |
| 732 """Runs cpplint.py on all the files in |change_info|""" | 732 """Runs cpplint.py on all the files in |change_info|""" |
| 733 try: | 733 try: |
| 734 import cpplint | 734 import cpplint |
| 735 except ImportError: | 735 except ImportError: |
| 736 ErrorExit("You need to install cpplint.py to lint C++ files.") | 736 ErrorExit("You need to install cpplint.py to lint C++ files.") |
| 737 | 737 |
| 738 for file_record in change_info.files: | 738 # Change the current working directory before calling lint so that it |
| 739 file = file_record[1] | 739 # shows the correct base. |
| 740 os.chdir(GetRepositoryRoot()) |
| 740 | 741 |
| 742 # Process cpplints arguments if any. |
| 743 filenames = cpplint.ParseArguments(args + change_info.FileList()) |
| 744 |
| 745 for file in filenames: |
| 741 if len([file for suffix in CPP_EXTENSIONS if file.endswith(suffix)]): | 746 if len([file for suffix in CPP_EXTENSIONS if file.endswith(suffix)]): |
| 742 if len([file for prefix in IGNORE_PATHS if file.startswith(prefix)]): | 747 if len([file for prefix in IGNORE_PATHS if file.startswith(prefix)]): |
| 743 print "Ignoring non-Google styled file %s" % file | 748 print "Ignoring non-Google styled file %s" % file |
| 744 else: | 749 else: |
| 745 cpplint.ProcessFile(file, 0) | 750 cpplint.ProcessFile(file, cpplint._cpplint_state.verbose_level) |
| 751 |
| 752 print "Total errors found: %d\n" % cpplint._cpplint_state.error_count |
| 746 | 753 |
| 747 | 754 |
| 748 def Changes(): | 755 def Changes(): |
| 749 """Print all the changlists and their files.""" | 756 """Print all the changlists and their files.""" |
| 750 for cl in GetCLs(): | 757 for cl in GetCLs(): |
| 751 change_info = LoadChangelistInfo(cl, True, True) | 758 change_info = LoadChangelistInfo(cl, True, True) |
| 752 print "\n--- Changelist " + change_info.name + ":" | 759 print "\n--- Changelist " + change_info.name + ":" |
| 753 for file in change_info.files: | 760 for file in change_info.files: |
| 754 print "".join(file) | 761 print "".join(file) |
| 755 | 762 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 # change didn't exist. All other commands require an existing change. | 811 # change didn't exist. All other commands require an existing change. |
| 805 fail_on_not_found = command != "try" and command != "change" | 812 fail_on_not_found = command != "try" and command != "change" |
| 806 if command == "try" and changename.find(',') != -1: | 813 if command == "try" and changename.find(',') != -1: |
| 807 change_info = LoadChangelistInfoForMultiple(changename, True, True) | 814 change_info = LoadChangelistInfoForMultiple(changename, True, True) |
| 808 else: | 815 else: |
| 809 change_info = LoadChangelistInfo(changename, fail_on_not_found, True) | 816 change_info = LoadChangelistInfo(changename, fail_on_not_found, True) |
| 810 | 817 |
| 811 if command == "change": | 818 if command == "change": |
| 812 Change(change_info) | 819 Change(change_info) |
| 813 elif command == "lint": | 820 elif command == "lint": |
| 814 Lint(change_info) | 821 Lint(change_info, argv[3:]) |
| 815 elif command == "upload": | 822 elif command == "upload": |
| 816 UploadCL(change_info, argv[3:]) | 823 UploadCL(change_info, argv[3:]) |
| 817 elif command == "commit": | 824 elif command == "commit": |
| 818 Commit(change_info, argv[3:]) | 825 Commit(change_info, argv[3:]) |
| 819 elif command == "delete": | 826 elif command == "delete": |
| 820 change_info.Delete() | 827 change_info.Delete() |
| 821 elif command == "try": | 828 elif command == "try": |
| 822 # When the change contains no file, send the "changename" positional | 829 # When the change contains no file, send the "changename" positional |
| 823 # argument to trychange.py. | 830 # argument to trychange.py. |
| 824 if change_info.files: | 831 if change_info.files: |
| 825 args = argv[3:] | 832 args = argv[3:] |
| 826 else: | 833 else: |
| 827 change_info = None | 834 change_info = None |
| 828 args = argv[2:] | 835 args = argv[2:] |
| 829 TryChange(change_info, args) | 836 TryChange(change_info, args) |
| 830 else: | 837 else: |
| 831 # Everything else that is passed into gcl we redirect to svn, after adding | 838 # Everything else that is passed into gcl we redirect to svn, after adding |
| 832 # the files. This allows commands such as 'gcl diff xxx' to work. | 839 # the files. This allows commands such as 'gcl diff xxx' to work. |
| 833 args =["svn", command] | 840 args =["svn", command] |
| 834 root = GetRepositoryRoot() | 841 root = GetRepositoryRoot() |
| 835 args.extend([os.path.join(root, x) for x in change_info.FileList()]) | 842 args.extend([os.path.join(root, x) for x in change_info.FileList()]) |
| 836 RunShell(args, True) | 843 RunShell(args, True) |
| 837 return 0 | 844 return 0 |
| 838 | 845 |
| 839 | 846 |
| 840 if __name__ == "__main__": | 847 if __name__ == "__main__": |
| 841 sys.exit(main()) | 848 sys.exit(main()) |
| OLD | NEW |