Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: gcl.py

Issue 160139: Get rid of annoying empty changelists!... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: s/clear/delete Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/gcl_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 gcl status 674 gcl status
675 Lists modified and unknown files in the current directory and 675 Lists modified and unknown files in the current directory and
676 subdirectories. 676 subdirectories.
677 677
678 gcl try change_name 678 gcl try change_name
679 Sends the change to the tryserver so a trybot can do a test run on your 679 Sends the change to the tryserver so a trybot can do a test run on your
680 code. To send multiple changes as one path, use a comma-separated list 680 code. To send multiple changes as one path, use a comma-separated list
681 of changenames. 681 of changenames.
682 --> Use 'gcl help try' for more information! 682 --> Use 'gcl help try' for more information!
683 683
684 gcl deleteempties
685 Deletes all changelists that have no files associated with them. Careful,
686 you can lose your descriptions.
687
684 gcl help [command] 688 gcl help [command]
685 Print this help menu, or help for the given command if it exists. 689 Print this help menu, or help for the given command if it exists.
686 """) 690 """)
687 691
688 def GetEditor(): 692 def GetEditor():
689 editor = os.environ.get("SVN_EDITOR") 693 editor = os.environ.get("SVN_EDITOR")
690 if not editor: 694 if not editor:
691 editor = os.environ.get("EDITOR") 695 editor = os.environ.get("EDITOR")
692 696
693 if not editor: 697 if not editor:
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 change_info.Save() 970 change_info.Save()
967 else: 971 else:
968 ErrorExit("Error getting the description from Rietveld: " + err) 972 ErrorExit("Error getting the description from Rietveld: " + err)
969 else: 973 else:
970 if override_description: 974 if override_description:
971 description = override_description 975 description = override_description
972 else: 976 else:
973 description = change_info.description 977 description = change_info.description
974 978
975 other_files = GetFilesNotInCL() 979 other_files = GetFilesNotInCL()
976 980
977 #Edited files will have a letter for the first character in a string. 981 #Edited files will have a letter for the first character in a string.
978 #This regex looks for the presence of that character. 982 #This regex looks for the presence of that character.
979 file_re = re.compile(r"^[a-z].+\Z", re.IGNORECASE) 983 file_re = re.compile(r"^[a-z].+\Z", re.IGNORECASE)
980 affected_files = filter(lambda x: file_re.match(x[0]), other_files) 984 affected_files = filter(lambda x: file_re.match(x[0]), other_files)
981 unaffected_files = filter(lambda x: not file_re.match(x[0]), other_files) 985 unaffected_files = filter(lambda x: not file_re.match(x[0]), other_files)
982 986
983 separator1 = ("\n---All lines above this line become the description.\n" 987 separator1 = ("\n---All lines above this line become the description.\n"
984 "---Repository Root: " + change_info.GetLocalRoot() + "\n" 988 "---Repository Root: " + change_info.GetLocalRoot() + "\n"
985 "---Paths in this changelist (" + change_info.name + "):\n") 989 "---Paths in this changelist (" + change_info.name + "):\n")
986 separator2 = "\n\n---Paths modified but not in any changelist:\n\n" 990 separator2 = "\n\n---Paths modified but not in any changelist:\n\n"
(...skipping 29 matching lines...) Expand all
1016 1020
1017 new_cl_files = [] 1021 new_cl_files = []
1018 for line in cl_files_text.splitlines(): 1022 for line in cl_files_text.splitlines():
1019 if not len(line): 1023 if not len(line):
1020 continue 1024 continue
1021 if line.startswith("---"): 1025 if line.startswith("---"):
1022 break 1026 break
1023 status = line[:7] 1027 status = line[:7]
1024 file = line[7:] 1028 file = line[7:]
1025 new_cl_files.append((status, file)) 1029 new_cl_files.append((status, file))
1030
1031 if (not len(change_info._files)) and (not change_info.issue) and \
1032 (not len(new_description) and (not new_cl_files)):
1033 ErrorExit("Empty changelist not saved")
1034
1026 change_info._files = new_cl_files 1035 change_info._files = new_cl_files
1027 1036
1028 change_info.Save() 1037 change_info.Save()
1029 print change_info.name + " changelist saved." 1038 print change_info.name + " changelist saved."
1030 if change_info.MissingTests(): 1039 if change_info.MissingTests():
1031 Warn("WARNING: " + MISSING_TEST_MSG) 1040 Warn("WARNING: " + MISSING_TEST_MSG)
1032 1041
1033 # We don't lint files in these path prefixes. 1042 # We don't lint files in these path prefixes.
1034 IGNORE_PATHS = ("webkit",) 1043 IGNORE_PATHS = ("webkit",)
1035 1044
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 1096
1088 def Changes(): 1097 def Changes():
1089 """Print all the changelists and their files.""" 1098 """Print all the changelists and their files."""
1090 for cl in GetCLs(): 1099 for cl in GetCLs():
1091 change_info = ChangeInfo.Load(cl, GetRepositoryRoot(), True, True) 1100 change_info = ChangeInfo.Load(cl, GetRepositoryRoot(), True, True)
1092 print "\n--- Changelist " + change_info.name + ":" 1101 print "\n--- Changelist " + change_info.name + ":"
1093 for file in change_info.GetFiles(): 1102 for file in change_info.GetFiles():
1094 print "".join(file) 1103 print "".join(file)
1095 1104
1096 1105
1106 def DeleteEmptyChangeLists():
1107 """Delete all changelists that have no files."""
1108 print "\n--- Deleting:"
1109 for cl in GetCLs():
1110 change_info = ChangeInfo.Load(cl, GetRepositoryRoot(), True, True)
1111 if not len(change_info._files):
1112 print change_info.name
1113 change_info.Delete()
1114
1115
1097 def main(argv=None): 1116 def main(argv=None):
1098 if argv is None: 1117 if argv is None:
1099 argv = sys.argv 1118 argv = sys.argv
1100 1119
1101 if len(argv) == 1: 1120 if len(argv) == 1:
1102 Help() 1121 Help()
1103 return 0; 1122 return 0;
1104 1123
1105 try: 1124 try:
1106 # Create the directories where we store information about changelists if it 1125 # Create the directories where we store information about changelists if it
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 if command == "diff" and len(argv) == 2: 1163 if command == "diff" and len(argv) == 2:
1145 files = GetFilesNotInCL() 1164 files = GetFilesNotInCL()
1146 print GenerateDiff([x[1] for x in files]) 1165 print GenerateDiff([x[1] for x in files])
1147 return 0 1166 return 0
1148 if command == "settings": 1167 if command == "settings":
1149 ignore = GetCodeReviewSetting("UNKNOWN"); 1168 ignore = GetCodeReviewSetting("UNKNOWN");
1150 del CODEREVIEW_SETTINGS['__just_initialized'] 1169 del CODEREVIEW_SETTINGS['__just_initialized']
1151 print '\n'.join(("%s: %s" % (str(k), str(v)) 1170 print '\n'.join(("%s: %s" % (str(k), str(v))
1152 for (k,v) in CODEREVIEW_SETTINGS.iteritems())) 1171 for (k,v) in CODEREVIEW_SETTINGS.iteritems()))
1153 return 0 1172 return 0
1173 if command == "deleteempties":
1174 DeleteEmptyChangeLists()
1175 return 0
1154 1176
1155 if len(argv) == 2: 1177 if len(argv) == 2:
1156 if command == "change": 1178 if command == "change":
1157 # Generate a random changelist name. 1179 # Generate a random changelist name.
1158 changename = GenerateChangeName() 1180 changename = GenerateChangeName()
1159 else: 1181 else:
1160 ErrorExit("Need a changelist name.") 1182 ErrorExit("Need a changelist name.")
1161 else: 1183 else:
1162 changename = argv[2] 1184 changename = argv[2]
1163 1185
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 # the files. This allows commands such as 'gcl diff xxx' to work. 1227 # the files. This allows commands such as 'gcl diff xxx' to work.
1206 args =["svn", command] 1228 args =["svn", command]
1207 root = GetRepositoryRoot() 1229 root = GetRepositoryRoot()
1208 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) 1230 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()])
1209 RunShell(args, True) 1231 RunShell(args, True)
1210 return 0 1232 return 0
1211 1233
1212 1234
1213 if __name__ == "__main__": 1235 if __name__ == "__main__":
1214 sys.exit(main()) 1236 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698