Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 if len(port_revision_list) > 0: | 92 if len(port_revision_list) > 0: |
| 93 if self.Confirm("Automatically add corresponding ports (%s)?" | 93 if self.Confirm("Automatically add corresponding ports (%s)?" |
| 94 % ", ".join(port_revision_list)): | 94 % ", ".join(port_revision_list)): |
| 95 #: 'y': Add ports to revision list. | 95 #: 'y': Add ports to revision list. |
| 96 self["full_revision_list"].extend(port_revision_list) | 96 self["full_revision_list"].extend(port_revision_list) |
| 97 | 97 |
| 98 | 98 |
| 99 class CreateCommitMessage(Step): | 99 class CreateCommitMessage(Step): |
| 100 MESSAGE = "Create commit message." | 100 MESSAGE = "Create commit message." |
| 101 | 101 |
| 102 def _create_commit_description(self, commit_hash): | |
| 103 patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) | |
| 104 description = "Merged: " + patch_merge_desc + "\n" | |
| 105 description = description + "Hash: " + commit_hash + "\n\n" | |
|
Michael Achenbach
2015/10/21 12:32:35
Maybe s/Hash/Revision
Michael Hablich
2015/10/21 12:41:26
You mean like Hash: 4df56dsssss r12345
?
Michael Achenbach
2015/10/21 12:51:17
No I mean literally. Use the more commonly used wo
Michael Hablich
2015/10/22 14:25:50
Acknowledged.
| |
| 106 return description | |
| 107 | |
| 102 def RunStep(self): | 108 def RunStep(self): |
| 103 | 109 |
| 104 # Stringify: ["abcde", "12345"] -> "abcde, 12345" | 110 # Stringify: ["abcde", "12345"] -> "abcde, 12345" |
| 105 self["revision_list"] = ", ".join(self["full_revision_list"]) | 111 self["revision_list"] = ", ".join(self["full_revision_list"]) |
| 106 | 112 |
| 107 if not self["revision_list"]: # pragma: no cover | 113 if not self["revision_list"]: # pragma: no cover |
| 108 self.Die("Revision list is empty.") | 114 self.Die("Revision list is empty.") |
| 109 | 115 |
| 110 action_text = "Merged %s" | 116 msg_pieces = [] |
| 111 | 117 |
| 112 # The commit message title is added below after the version is specified. | 118 if len(self["full_revision_list"]) > 1: |
| 113 msg_pieces = [ | 119 self["commit_title"] = "Merged: Squashed multiple commits." |
| 114 "\n".join(action_text % s for s in self["full_revision_list"]), | 120 else: |
| 115 ] | 121 commit_hash = self["full_revision_list"][0] |
|
Michael Achenbach
2015/10/21 12:32:35
Why not make a pure cherry-pick in case of one com
Michael Hablich
2015/10/21 12:41:26
I didn't want to introduce more complexity into th
Michael Achenbach
2015/10/21 12:51:17
It offers the full original commit message instead
Michael Hablich
2015/10/22 14:25:49
So, I tried cherry-picks on our branches a few tim
| |
| 116 msg_pieces.append("\n\n") | 122 patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) |
| 123 title = "Merged: " + patch_merge_desc | |
| 124 self["commit_title"] = title | |
| 117 | 125 |
| 118 for commit_hash in self["full_revision_list"]: | 126 for commit_hash in self["full_revision_list"]: |
| 119 patch_merge_desc = self.GitLog(n=1, format="%s", git_hash=commit_hash) | 127 msg_pieces.append(self._create_commit_description(commit_hash)) |
| 120 msg_pieces.append("%s\n\n" % patch_merge_desc) | |
| 121 | 128 |
| 122 bugs = [] | 129 bugs = [] |
| 123 for commit_hash in self["full_revision_list"]: | 130 for commit_hash in self["full_revision_list"]: |
| 124 msg = self.GitLog(n=1, git_hash=commit_hash) | 131 msg = self.GitLog(n=1, git_hash=commit_hash) |
| 125 for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg, re.M): | 132 for bug in re.findall(r"^[ \t]*BUG[ \t]*=[ \t]*(.*?)[ \t]*$", msg, re.M): |
| 126 bugs.extend(s.strip() for s in bug.split(",")) | 133 bugs.extend(s.strip() for s in bug.split(",")) |
| 127 bug_aggregate = ",".join(sorted(filter(lambda s: s and s != "none", bugs))) | 134 bug_aggregate = ",".join(sorted(filter(lambda s: s and s != "none", bugs))) |
| 128 if bug_aggregate: | 135 if bug_aggregate: |
| 129 msg_pieces.append("BUG=%s\nLOG=N\n" % bug_aggregate) | 136 msg_pieces.append("BUG=%s\nLOG=N\n" % bug_aggregate) |
| 130 | 137 |
| 131 self["new_commit_msg"] = "".join(msg_pieces) | 138 self["new_commit_msg"] = "".join(msg_pieces) |
| 132 | 139 |
| 133 | 140 |
| 134 class ApplyPatches(Step): | 141 class ApplyPatches(Step): |
| 135 MESSAGE = "Apply patches for selected revisions." | 142 MESSAGE = "Apply patches for selected revisions." |
| 136 | 143 |
| 137 def RunStep(self): | 144 def RunStep(self): |
| 138 for commit_hash in self["full_revision_list"]: | 145 for commit_hash in self["full_revision_list"]: |
| 139 print("Applying patch for %s to %s..." | 146 print("Applying patch for %s to %s..." |
| 140 % (commit_hash, self["merge_to_branch"])) | 147 % (commit_hash, self["merge_to_branch"])) |
| 141 patch = self.GitGetPatch(commit_hash) | 148 patch = self.GitGetPatch(commit_hash) |
| 142 TextToFile(patch, self.Config("TEMPORARY_PATCH_FILE")) | 149 TextToFile(patch, self.Config("TEMPORARY_PATCH_FILE")) |
| 143 self.ApplyPatch(self.Config("TEMPORARY_PATCH_FILE")) | 150 self.ApplyPatch(self.Config("TEMPORARY_PATCH_FILE")) |
| 144 if self._options.patch: | 151 if self._options.patch: |
| 145 self.ApplyPatch(self._options.patch) | 152 self.ApplyPatch(self._options.patch) |
| 146 | 153 |
| 147 | |
| 148 class PrepareVersion(Step): | |
| 149 MESSAGE = "Prepare version file." | |
| 150 | |
| 151 def RunStep(self): | |
| 152 # This is used to calculate the patch level increment. | |
| 153 self.ReadAndPersistVersion() | |
| 154 | |
| 155 | |
| 156 class IncrementVersion(Step): | |
| 157 MESSAGE = "Increment version number." | |
| 158 | |
| 159 def RunStep(self): | |
| 160 new_patch = str(int(self["patch"]) + 1) | |
| 161 if self.Confirm("Automatically increment V8_PATCH_LEVEL? (Saying 'n' will " | |
| 162 "fire up your EDITOR on %s so you can make arbitrary " | |
| 163 "changes. When you're done, save the file and exit your " | |
| 164 "EDITOR.)" % VERSION_FILE): | |
| 165 text = FileToText(os.path.join(self.default_cwd, VERSION_FILE)) | |
| 166 text = MSub(r"(?<=#define V8_PATCH_LEVEL)(?P<space>\s+)\d*$", | |
| 167 r"\g<space>%s" % new_patch, | |
| 168 text) | |
| 169 TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE)) | |
| 170 else: | |
| 171 self.Editor(os.path.join(self.default_cwd, VERSION_FILE)) | |
| 172 self.ReadAndPersistVersion("new_") | |
| 173 self["version"] = "%s.%s.%s.%s" % (self["new_major"], | |
| 174 self["new_minor"], | |
| 175 self["new_build"], | |
| 176 self["new_patch"]) | |
| 177 | |
| 178 | |
| 179 class CommitLocal(Step): | 154 class CommitLocal(Step): |
| 180 MESSAGE = "Commit to local branch." | 155 MESSAGE = "Commit to local branch." |
| 181 | 156 |
| 182 def RunStep(self): | 157 def RunStep(self): |
| 183 # Add a commit message title. | 158 # Add a commit message title. |
| 184 self["commit_title"] = "Version %s (cherry-pick)" % self["version"] | |
| 185 self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"], | 159 self["new_commit_msg"] = "%s\n\n%s" % (self["commit_title"], |
| 186 self["new_commit_msg"]) | 160 self["new_commit_msg"]) |
| 187 TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE")) | 161 TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE")) |
| 188 self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) | 162 self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) |
| 189 | 163 |
| 190 | 164 |
| 191 class CommitRepository(Step): | 165 class CommitRepository(Step): |
| 192 MESSAGE = "Commit to the repository." | 166 MESSAGE = "Commit to the repository." |
| 193 | 167 |
| 194 def RunStep(self): | 168 def RunStep(self): |
| 195 self.GitCheckout(self.Config("BRANCHNAME")) | 169 self.GitCheckout(self.Config("BRANCHNAME")) |
| 196 self.WaitForLGTM() | 170 self.WaitForLGTM() |
| 197 self.GitPresubmit() | 171 self.GitPresubmit() |
| 198 self.vc.CLLand() | 172 self.vc.CLLand() |
| 199 | 173 |
| 200 | |
| 201 class TagRevision(Step): | |
| 202 MESSAGE = "Create the tag." | |
| 203 | |
| 204 def RunStep(self): | |
| 205 print "Creating tag %s" % self["version"] | |
| 206 self.vc.Tag(self["version"], | |
| 207 self.vc.RemoteBranch(self["merge_to_branch"]), | |
| 208 self["commit_title"]) | |
| 209 | |
| 210 | |
| 211 class CleanUp(Step): | 174 class CleanUp(Step): |
| 212 MESSAGE = "Cleanup." | 175 MESSAGE = "Cleanup." |
| 213 | 176 |
| 214 def RunStep(self): | 177 def RunStep(self): |
| 215 self.CommonCleanup() | 178 self.CommonCleanup() |
| 216 print "*** SUMMARY ***" | 179 print "*** SUMMARY ***" |
| 217 print "version: %s" % self["version"] | 180 print "version: %s" % self["version"] |
|
Michael Achenbach
2015/10/21 12:32:35
Remove version output.
Michael Hablich
2015/10/21 12:41:26
Ack.
| |
| 218 print "branch: %s" % self["merge_to_branch"] | 181 print "branch: %s" % self["merge_to_branch"] |
| 219 if self["revision_list"]: | 182 if self["revision_list"]: |
| 220 print "patches: %s" % self["revision_list"] | 183 print "patches: %s" % self["revision_list"] |
| 221 | 184 |
| 222 | 185 |
| 223 class MergeToBranch(ScriptsBase): | 186 class MergeToBranch(ScriptsBase): |
| 224 def _Description(self): | 187 def _Description(self): |
| 225 return ("Performs the necessary steps to merge revisions from " | 188 return ("Performs the necessary steps to merge revisions from " |
| 226 "master to other branches, including candidates.") | 189 "master to other branches, including candidates.") |
| 227 | 190 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 "COMMITMSG_FILE": "/tmp/v8-prepare-merge-tempfile-commitmsg", | 232 "COMMITMSG_FILE": "/tmp/v8-prepare-merge-tempfile-commitmsg", |
| 270 } | 233 } |
| 271 | 234 |
| 272 def _Steps(self): | 235 def _Steps(self): |
| 273 return [ | 236 return [ |
| 274 Preparation, | 237 Preparation, |
| 275 CreateBranch, | 238 CreateBranch, |
| 276 SearchArchitecturePorts, | 239 SearchArchitecturePorts, |
| 277 CreateCommitMessage, | 240 CreateCommitMessage, |
| 278 ApplyPatches, | 241 ApplyPatches, |
| 279 PrepareVersion, | 242 # PrepareVersion, |
|
Michael Achenbach
2015/10/21 12:32:35
nit: Remove the comments.
Michael Achenbach
2015/10/21 12:38:37
Done.
Michael Hablich
2015/10/21 12:41:26
Done.
| |
| 280 IncrementVersion, | 243 # IncrementVersion, |
| 281 CommitLocal, | 244 CommitLocal, |
| 282 UploadStep, | 245 UploadStep, |
|
Michael Achenbach
2015/10/21 12:32:35
Maybe make the upload step configurable and let it
Michael Hablich
2015/10/21 12:41:26
I don't think more configuration will help.
Addi
Michael Achenbach
2015/10/21 12:51:17
I don't care how it would be done technically. But
| |
| 283 CommitRepository, | 246 CommitRepository, |
| 284 TagRevision, | 247 # TagRevision, |
| 285 CleanUp, | 248 CleanUp, |
| 286 ] | 249 ] |
| 287 | 250 |
| 288 | 251 |
| 289 if __name__ == "__main__": # pragma: no cover | 252 if __name__ == "__main__": # pragma: no cover |
| 290 sys.exit(MergeToBranch().Run()) | 253 sys.exit(MergeToBranch().Run()) |
| OLD | NEW |