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

Side by Side Diff: gcl.py

Issue 294005: gcl: Make fix the override_description code and add a silent flag.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « drover.py ('k') | no next file » | 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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 revision = re.compile(".*?\nCommitted revision (\d+)", 969 revision = re.compile(".*?\nCommitted revision (\d+)",
970 re.DOTALL).match(output).group(1) 970 re.DOTALL).match(output).group(1)
971 viewvc_url = GetCodeReviewSetting("VIEW_VC") 971 viewvc_url = GetCodeReviewSetting("VIEW_VC")
972 change_info.description = change_info.description + '\n' 972 change_info.description = change_info.description + '\n'
973 if viewvc_url: 973 if viewvc_url:
974 change_info.description += "\nCommitted: " + viewvc_url + revision 974 change_info.description += "\nCommitted: " + viewvc_url + revision
975 change_info.CloseIssue() 975 change_info.CloseIssue()
976 os.chdir(previous_cwd) 976 os.chdir(previous_cwd)
977 977
978 978
979 def Change(change_info, override_description): 979 def Change(change_info, args):
980 """Creates/edits a changelist.""" 980 """Creates/edits a changelist."""
981 silent = FilterFlag(args, "--silent")
982 if (len(args) == 1):
983 filename = args[0]
984 f = open(filename, 'rU')
985 override_description = f.read()
986 f.close()
987 else:
988 override_description = None
989
981 if change_info.issue: 990 if change_info.issue:
982 try: 991 try:
983 description = GetIssueDescription(change_info.issue) 992 description = GetIssueDescription(change_info.issue)
984 except urllib2.HTTPError, err: 993 except urllib2.HTTPError, err:
985 if err.code == 404: 994 if err.code == 404:
986 # The user deleted the issue in Rietveld, so forget the old issue id. 995 # The user deleted the issue in Rietveld, so forget the old issue id.
987 description = change_info.description 996 description = change_info.description
988 change_info.issue = 0 997 change_info.issue = 0
989 change_info.Save() 998 change_info.Save()
990 else: 999 else:
(...skipping 24 matching lines...) Expand all
1015 '\n'.join([f[0] + f[1] for f in affected_files]) + '\n') 1024 '\n'.join([f[0] + f[1] for f in affected_files]) + '\n')
1016 else: 1025 else:
1017 text += ('\n'.join([f[0] + f[1] for f in affected_files]) + '\n' + 1026 text += ('\n'.join([f[0] + f[1] for f in affected_files]) + '\n' +
1018 separator2) 1027 separator2)
1019 text += '\n'.join([f[0] + f[1] for f in unaffected_files]) + '\n' 1028 text += '\n'.join([f[0] + f[1] for f in unaffected_files]) + '\n'
1020 1029
1021 handle, filename = tempfile.mkstemp(text=True) 1030 handle, filename = tempfile.mkstemp(text=True)
1022 os.write(handle, text) 1031 os.write(handle, text)
1023 os.close(handle) 1032 os.close(handle)
1024 1033
1025 os.system(GetEditor() + " " + filename) 1034 if not silent:
1035 os.system(GetEditor() + " " + filename)
1026 1036
1027 result = ReadFile(filename) 1037 result = ReadFile(filename)
1028 os.remove(filename) 1038 os.remove(filename)
1029 1039
1030 if not result: 1040 if not result:
1031 return 1041 return
1032 1042
1033 split_result = result.split(separator1, 1) 1043 split_result = result.split(separator1, 1)
1034 if len(split_result) != 2: 1044 if len(split_result) != 2:
1035 ErrorExit("Don't modify the text starting with ---!\n\n" + result) 1045 ErrorExit("Don't modify the text starting with ---!\n\n" + result)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 # change didn't exist. All other commands require an existing change. 1219 # change didn't exist. All other commands require an existing change.
1210 fail_on_not_found = command != "try" and command != "change" 1220 fail_on_not_found = command != "try" and command != "change"
1211 if command == "try" and changename.find(',') != -1: 1221 if command == "try" and changename.find(',') != -1:
1212 change_info = LoadChangelistInfoForMultiple(changename, GetRepositoryRoot(), 1222 change_info = LoadChangelistInfoForMultiple(changename, GetRepositoryRoot(),
1213 True, True) 1223 True, True)
1214 else: 1224 else:
1215 change_info = ChangeInfo.Load(changename, GetRepositoryRoot(), 1225 change_info = ChangeInfo.Load(changename, GetRepositoryRoot(),
1216 fail_on_not_found, True) 1226 fail_on_not_found, True)
1217 1227
1218 if command == "change": 1228 if command == "change":
1219 if (len(argv) == 4): 1229 Change(change_info, argv[3:])
1220 filename = argv[3]
1221 f = open(filename, 'rU')
1222 override_description = f.read()
1223 f.close()
1224 else:
1225 override_description = None
1226 Change(change_info, override_description)
1227 elif command == "lint": 1230 elif command == "lint":
1228 Lint(change_info, argv[3:]) 1231 Lint(change_info, argv[3:])
1229 elif command == "upload": 1232 elif command == "upload":
1230 UploadCL(change_info, argv[3:]) 1233 UploadCL(change_info, argv[3:])
1231 elif command == "presubmit": 1234 elif command == "presubmit":
1232 PresubmitCL(change_info) 1235 PresubmitCL(change_info)
1233 elif command in ("commit", "submit"): 1236 elif command in ("commit", "submit"):
1234 Commit(change_info, argv[3:]) 1237 Commit(change_info, argv[3:])
1235 elif command == "delete": 1238 elif command == "delete":
1236 change_info.Delete() 1239 change_info.Delete()
(...skipping 11 matching lines...) Expand all
1248 # the files. This allows commands such as 'gcl diff xxx' to work. 1251 # the files. This allows commands such as 'gcl diff xxx' to work.
1249 args =["svn", command] 1252 args =["svn", command]
1250 root = GetRepositoryRoot() 1253 root = GetRepositoryRoot()
1251 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()]) 1254 args.extend([os.path.join(root, x) for x in change_info.GetFileNames()])
1252 RunShell(args, True) 1255 RunShell(args, True)
1253 return 0 1256 return 0
1254 1257
1255 1258
1256 if __name__ == "__main__": 1259 if __name__ == "__main__":
1257 sys.exit(main()) 1260 sys.exit(main())
OLDNEW
« no previous file with comments | « drover.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698