From 85532fc2e5c4d1bfe1262214ecb9446b411c6e22 Mon Sep 17 00:00:00 2001 From: "laforge@chromium.org" Date: Thu, 4 Jun 2009 22:36:53 +0000 Subject: [PATCH] Added some new functionality to gcl: - Create a new parameter for "gcl change 12354 " to read comments from a text file. This allows us to programmatically inject comments into a gcl upload - Added helper methods in change to order of which other_files have changed (brings changed files to the top of the list). This makes it easier to find which files have change, and simply cut and paste the top of the list (after many merges, the list of unmodified files grows to be quite extensive... very useful) git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@17684 0039d316-1c4b-4281-b951-d872f2087c98 --- gcl.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gcl.py b/gcl.py index e281baaec4..762a2883c1 100755 --- a/gcl.py +++ b/gcl.py @@ -912,8 +912,7 @@ def Commit(change_info, args): change_info.CloseIssue() os.chdir(previous_cwd) - -def Change(change_info): +def Change(change_info, override_description): """Creates/edits a changelist.""" if change_info.issue: try: @@ -927,9 +926,18 @@ def Change(change_info): else: ErrorExit("Error getting the description from Rietveld: " + err) else: - description = change_info.description + if override_description: + description = override_description + else: + description = change_info.description other_files = GetFilesNotInCL() + + #Edited files will have a letter for the first character in a string. + #This regex looks for the presence of that character. + file_re = re.compile(r"^[a-z].+\Z", re.IGNORECASE) + affected_files = filter(lambda x: file_re.match(x[0]), other_files) + unaffected_files = filter(lambda x: not file_re.match(x[0]), other_files) separator1 = ("\n---All lines above this line become the description.\n" "---Repository Root: " + GetRepositoryRoot() + "\n" @@ -937,7 +945,8 @@ def Change(change_info): separator2 = "\n\n---Paths modified but not in any changelist:\n\n" text = (description + separator1 + '\n' + '\n'.join([f[0] + f[1] for f in change_info.files]) + separator2 + - '\n'.join([f[0] + f[1] for f in other_files]) + '\n') + '\n'.join([f[0] + f[1] for f in affected_files]) + '\n' + + '\n'.join([f[0] + f[1] for f in unaffected_files]) + '\n') handle, filename = tempfile.mkstemp(text=True) os.write(handle, text) @@ -957,7 +966,7 @@ def Change(change_info): new_description = split_result[0] cl_files_text = split_result[1] - if new_description != description: + if new_description != description or override_description: change_info.description = new_description if change_info.issue: # Update the Rietveld issue with the new description. @@ -1107,7 +1116,14 @@ def main(argv=None): change_info = LoadChangelistInfo(changename, fail_on_not_found, True) if command == "change": - Change(change_info) + if (len(argv) == 4): + filename = argv[3] + f = open(filename, 'rU') + override_description = f.read() + f.close() + else: + override_description = None + Change(change_info, override_description) elif command == "lint": Lint(change_info, argv[3:]) elif command == "upload":