 Chromium Code Reviews
 Chromium Code Reviews Issue 1398033003:
  [Release] Update merge script to leverage auto-tag bot  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1398033003:
  [Release] Update merge script to leverage auto-tag bot  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| Index: tools/release/merge_to_branch.py | 
| diff --git a/tools/release/merge_to_branch.py b/tools/release/merge_to_branch.py | 
| index 699fe1b3c66dbc5fc67970616eb811136ecad844..ead4ce0f7982cd170df1831bec2ef7122348d52a 100755 | 
| --- a/tools/release/merge_to_branch.py | 
| +++ b/tools/release/merge_to_branch.py | 
| @@ -47,10 +47,8 @@ class Preparation(Step): | 
| open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close() | 
| self.InitialEnvironmentChecks(self.default_cwd) | 
| - if self._options.branch: | 
| - self["merge_to_branch"] = self._options.branch | 
| - else: # pragma: no cover | 
| - self.Die("Please specify a branch to merge to") | 
| + | 
| + self["merge_to_branch"] = self._options.branch | 
| self.CommonPrepare() | 
| self.PrepareBranch() | 
| @@ -74,7 +72,7 @@ class SearchArchitecturePorts(Step): | 
| for revision in self["full_revision_list"]: | 
| # Search for commits which matches the "Port XXX" pattern. | 
| git_hashes = self.GitLog(reverse=True, format="%H", | 
| - grep="Port %s" % revision, | 
| + grep="^[Pp]ort %s" % revision, | 
| branch=self.vc.RemoteMasterBranch()) | 
| for git_hash in git_hashes.splitlines(): | 
| revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash) | 
| @@ -99,6 +97,12 @@ class SearchArchitecturePorts(Step): | 
| class CreateCommitMessage(Step): | 
| MESSAGE = "Create commit message." | 
| + def _create_commit_description(self, commit_hash): | 
| + patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) | 
| 
Michael Achenbach
2016/07/21 13:56:37
Is this done twice? E.g. below?
 
Michael Hablich
2016/07/21 14:27:33
Done.
 | 
| + description = "Merged: " + patch_merge_desc + "\n" | 
| + description = description + "Revision: " + commit_hash + "\n\n" | 
| 
Michael Achenbach
2016/07/21 13:56:37
nit: description += ...
or to avoid multiple stri
 
Michael Hablich
2016/07/21 14:27:32
Done.
 | 
| + return description | 
| + | 
| def RunStep(self): | 
| # Stringify: ["abcde", "12345"] -> "abcde, 12345" | 
| @@ -107,17 +111,18 @@ class CreateCommitMessage(Step): | 
| if not self["revision_list"]: # pragma: no cover | 
| self.Die("Revision list is empty.") | 
| - action_text = "Merged %s" | 
| + msg_pieces = [] | 
| - # The commit message title is added below after the version is specified. | 
| - msg_pieces = [ | 
| - "\n".join(action_text % s for s in self["full_revision_list"]), | 
| - ] | 
| - msg_pieces.append("\n\n") | 
| + if len(self["full_revision_list"]) > 1: | 
| + self["commit_title"] = "Merged: Squashed multiple commits." | 
| + else: | 
| + commit_hash = self["full_revision_list"][0] | 
| + patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) | 
| + title = "Merged: " + patch_merge_desc | 
| 
Michael Achenbach
2016/07/21 13:56:37
nit: inline title or also patch_merge_desc
 
Michael Hablich
2016/07/21 14:27:32
Done.
 | 
| + self["commit_title"] = title | 
| for commit_hash in self["full_revision_list"]: | 
| - patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) | 
| - msg_pieces.append("%s\n\n" % patch_merge_desc) | 
| + msg_pieces.append(self._create_commit_description(commit_hash)) | 
| 
Michael Achenbach
2016/07/21 13:56:37
Don't we get a double title here?
 
Michael Hablich
2016/07/21 14:27:33
Done.
 | 
| bugs = [] | 
| for commit_hash in self["full_revision_list"]: | 
| @@ -144,49 +149,28 @@ class ApplyPatches(Step): | 
| if self._options.patch: | 
| self.ApplyPatch(self._options.patch) | 
| - | 
| -class PrepareVersion(Step): | 
| - MESSAGE = "Prepare version file." | 
| - | 
| - def RunStep(self): | 
| - # This is used to calculate the patch level increment. | 
| - self.ReadAndPersistVersion() | 
| - | 
| - | 
| -class IncrementVersion(Step): | 
| - MESSAGE = "Increment version number." | 
| - | 
| - def RunStep(self): | 
| - new_patch = str(int(self["patch"]) + 1) | 
| - if self.Confirm("Automatically increment V8_PATCH_LEVEL? (Saying 'n' will " | 
| - "fire up your EDITOR on %s so you can make arbitrary " | 
| - "changes. When you're done, save the file and exit your " | 
| - "EDITOR.)" % VERSION_FILE): | 
| - text = FileToText(os.path.join(self.default_cwd, VERSION_FILE)) | 
| - text = MSub(r"(?<=#define V8_PATCH_LEVEL)(?P<space>\s+)\d*$", | 
| - r"\g<space>%s" % new_patch, | 
| - text) | 
| - TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE)) | 
| - else: | 
| - self.Editor(os.path.join(self.default_cwd, VERSION_FILE)) | 
| - self.ReadAndPersistVersion("new_") | 
| - self["version"] = "%s.%s.%s.%s" % (self["new_major"], | 
| - self["new_minor"], | 
| - self["new_build"], | 
| - self["new_patch"]) | 
| - | 
| - | 
| class CommitLocal(Step): | 
| MESSAGE = "Commit to local branch." | 
| def RunStep(self): | 
| # Add a commit message title. | 
| - self["commit_title"] = "Version %s (cherry-pick)" % self["version"] | 
| self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"], | 
| self["new_commit_msg"]) | 
| TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE")) | 
| self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) | 
| +class AddInformationalComment(Step): | 
| + MESSAGE = 'Show additional information.' | 
| + | 
| + def RunStep(self): | 
| + message = ("Please note that you are using a new " | 
| 
Michael Achenbach
2016/07/21 13:56:38
Suggestion for making this readable to lazy devs:
 
Michael Hablich
2016/07/21 14:27:33
Done.
 | 
| + "version of the script merge_to_branch.py. " | 
| + "This script will no longer automatically update include/v8-version.h " | 
| + "and create a tag. This is ok, the trustworthy autotag bot will " | 
| + "take care of that. The old script is still available in " | 
| + "tools/release/roll_merge.py.") | 
| + | 
| + self.GitCLAddComment(message) | 
| class CommitRepository(Step): | 
| MESSAGE = "Commit to the repository." | 
| @@ -197,24 +181,12 @@ class CommitRepository(Step): | 
| self.GitPresubmit() | 
| self.vc.CLLand() | 
| - | 
| -class TagRevision(Step): | 
| - MESSAGE = "Create the tag." | 
| - | 
| - def RunStep(self): | 
| - print "Creating tag %s" % self["version"] | 
| - self.vc.Tag(self["version"], | 
| - self.vc.RemoteBranch(self["merge_to_branch"]), | 
| - self["commit_title"]) | 
| - | 
| - | 
| class CleanUp(Step): | 
| MESSAGE = "Cleanup." | 
| def RunStep(self): | 
| self.CommonCleanup() | 
| print "*** SUMMARY ***" | 
| - print "version: %s" % self["version"] | 
| print "branch: %s" % self["merge_to_branch"] | 
| if self["revision_list"]: | 
| print "patches: %s" % self["revision_list"] | 
| @@ -223,7 +195,7 @@ class CleanUp(Step): | 
| class MergeToBranch(ScriptsBase): | 
| def _Description(self): | 
| return ("Performs the necessary steps to merge revisions from " | 
| 
Michael Achenbach
2016/07/21 13:56:38
Suggestion: Add more details here including all re
 
Michael Hablich
2016/07/21 14:27:33
Done.
 | 
| - "master to other branches, including candidates.") | 
| + "master to release branches like 4.5.") | 
| def _PrepareOptions(self, parser): | 
| group = parser.add_mutually_exclusive_group(required=True) | 
| @@ -250,6 +222,12 @@ class MergeToBranch(ScriptsBase): | 
| # CC ulan to make sure that fixes are merged to Google3. | 
| options.cc = "ulan@chromium.org" | 
| + # This script only supports official release branches, not roll branches | 
| 
Michael Achenbach
2016/07/21 13:56:37
nit: Comment is redundant to print message. Rather
 
Michael Hablich
2016/07/21 14:27:33
Done.
 | 
| + if len(options.branch.split('.')) > 2: | 
| + print ("This script does not support merging to roll branches (yet). " | 
| 
Michael Achenbach
2016/07/21 13:56:37
nit: remove 'yet' to avoid embarrassment when it's
 
Michael Hablich
2016/07/21 14:27:32
Done.
 | 
| + "Please use tools/release/roll_merge.py for this use case.") | 
| 
Michael Achenbach
2016/07/21 13:56:37
nit indentation - one space more...
 
Michael Hablich
2016/07/21 14:27:33
Done.
 | 
| + return False | 
| + | 
| # Make sure to use git hashes in the new workflows. | 
| for revision in options.revisions: | 
| if (IsSvnNumber(revision) or | 
| @@ -276,12 +254,10 @@ class MergeToBranch(ScriptsBase): | 
| SearchArchitecturePorts, | 
| CreateCommitMessage, | 
| ApplyPatches, | 
| - PrepareVersion, | 
| - IncrementVersion, | 
| CommitLocal, | 
| UploadStep, | 
| + AddInformationalComment, | 
| CommitRepository, | 
| - TagRevision, | 
| CleanUp, | 
| ] |