| 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 14 matching lines...) Expand all Loading... |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import argparse | 29 import argparse |
| 30 from collections import OrderedDict | 30 from collections import OrderedDict |
| 31 import sys | 31 import sys |
| 32 | 32 |
| 33 from common_includes import * | 33 from common_includes import * |
| 34 | 34 |
| 35 ALREADY_MERGING_SENTINEL_FILE = "ALREADY_MERGING_SENTINEL_FILE" | |
| 36 COMMIT_HASHES_FILE = "COMMIT_HASHES_FILE" | |
| 37 TEMPORARY_PATCH_FILE = "TEMPORARY_PATCH_FILE" | |
| 38 | |
| 39 CONFIG = { | |
| 40 BRANCHNAME: "prepare-merge", | |
| 41 PERSISTFILE_BASENAME: "/tmp/v8-merge-to-branch-tempfile", | |
| 42 ALREADY_MERGING_SENTINEL_FILE: | |
| 43 "/tmp/v8-merge-to-branch-tempfile-already-merging", | |
| 44 TEMPORARY_PATCH_FILE: "/tmp/v8-prepare-merge-tempfile-temporary-patch", | |
| 45 COMMITMSG_FILE: "/tmp/v8-prepare-merge-tempfile-commitmsg", | |
| 46 COMMIT_HASHES_FILE: "/tmp/v8-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", | |
| 47 } | |
| 48 | |
| 49 | |
| 50 class Preparation(Step): | 35 class Preparation(Step): |
| 51 MESSAGE = "Preparation." | 36 MESSAGE = "Preparation." |
| 52 | 37 |
| 53 def RunStep(self): | 38 def RunStep(self): |
| 54 if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)): | 39 if os.path.exists(self.Config("ALREADY_MERGING_SENTINEL_FILE")): |
| 55 if self._options.force: | 40 if self._options.force: |
| 56 os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE)) | 41 os.remove(self.Config("ALREADY_MERGING_SENTINEL_FILE")) |
| 57 elif self._options.step == 0: # pragma: no cover | 42 elif self._options.step == 0: # pragma: no cover |
| 58 self.Die("A merge is already in progress") | 43 self.Die("A merge is already in progress") |
| 59 open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close() | 44 open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close() |
| 60 | 45 |
| 61 self.InitialEnvironmentChecks(self.default_cwd) | 46 self.InitialEnvironmentChecks(self.default_cwd) |
| 62 if self._options.revert_bleeding_edge: | 47 if self._options.revert_bleeding_edge: |
| 63 self["merge_to_branch"] = "bleeding_edge" | 48 self["merge_to_branch"] = "bleeding_edge" |
| 64 elif self._options.branch: | 49 elif self._options.branch: |
| 65 self["merge_to_branch"] = self._options.branch | 50 self["merge_to_branch"] = self._options.branch |
| 66 else: # pragma: no cover | 51 else: # pragma: no cover |
| 67 self.Die("Please specify a branch to merge to") | 52 self.Die("Please specify a branch to merge to") |
| 68 | 53 |
| 69 self.CommonPrepare() | 54 self.CommonPrepare() |
| 70 self.PrepareBranch() | 55 self.PrepareBranch() |
| 71 | 56 |
| 72 | 57 |
| 73 class CreateBranch(Step): | 58 class CreateBranch(Step): |
| 74 MESSAGE = "Create a fresh branch for the patch." | 59 MESSAGE = "Create a fresh branch for the patch." |
| 75 | 60 |
| 76 def RunStep(self): | 61 def RunStep(self): |
| 77 self.GitCreateBranch(self.Config(BRANCHNAME), | 62 self.GitCreateBranch(self.Config("BRANCHNAME"), |
| 78 "svn/%s" % self["merge_to_branch"]) | 63 "svn/%s" % self["merge_to_branch"]) |
| 79 | 64 |
| 80 | 65 |
| 81 class SearchArchitecturePorts(Step): | 66 class SearchArchitecturePorts(Step): |
| 82 MESSAGE = "Search for corresponding architecture ports." | 67 MESSAGE = "Search for corresponding architecture ports." |
| 83 | 68 |
| 84 def RunStep(self): | 69 def RunStep(self): |
| 85 self["full_revision_list"] = list(OrderedDict.fromkeys( | 70 self["full_revision_list"] = list(OrderedDict.fromkeys( |
| 86 self._options.revisions)) | 71 self._options.revisions)) |
| 87 port_revision_list = [] | 72 port_revision_list = [] |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 135 |
| 151 | 136 |
| 152 class ApplyPatches(Step): | 137 class ApplyPatches(Step): |
| 153 MESSAGE = "Apply patches for selected revisions." | 138 MESSAGE = "Apply patches for selected revisions." |
| 154 | 139 |
| 155 def RunStep(self): | 140 def RunStep(self): |
| 156 for commit_hash in self["patch_commit_hashes"]: | 141 for commit_hash in self["patch_commit_hashes"]: |
| 157 print("Applying patch for %s to %s..." | 142 print("Applying patch for %s to %s..." |
| 158 % (commit_hash, self["merge_to_branch"])) | 143 % (commit_hash, self["merge_to_branch"])) |
| 159 patch = self.GitGetPatch(commit_hash) | 144 patch = self.GitGetPatch(commit_hash) |
| 160 TextToFile(patch, self.Config(TEMPORARY_PATCH_FILE)) | 145 TextToFile(patch, self.Config("TEMPORARY_PATCH_FILE")) |
| 161 self.ApplyPatch(self.Config(TEMPORARY_PATCH_FILE), self._options.revert) | 146 self.ApplyPatch(self.Config("TEMPORARY_PATCH_FILE"), self._options.revert) |
| 162 if self._options.patch: | 147 if self._options.patch: |
| 163 self.ApplyPatch(self._options.patch, self._options.revert) | 148 self.ApplyPatch(self._options.patch, self._options.revert) |
| 164 | 149 |
| 165 | 150 |
| 166 class PrepareVersion(Step): | 151 class PrepareVersion(Step): |
| 167 MESSAGE = "Prepare version file." | 152 MESSAGE = "Prepare version file." |
| 168 | 153 |
| 169 def RunStep(self): | 154 def RunStep(self): |
| 170 if self._options.revert_bleeding_edge: | 155 if self._options.revert_bleeding_edge: |
| 171 return | 156 return |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 if self._options.revert: | 191 if self._options.revert: |
| 207 if not self._options.revert_bleeding_edge: | 192 if not self._options.revert_bleeding_edge: |
| 208 title = ("Version %s (rollback of %s)" | 193 title = ("Version %s (rollback of %s)" |
| 209 % (self["version"], self["revision_list"])) | 194 % (self["version"], self["revision_list"])) |
| 210 else: | 195 else: |
| 211 title = "Revert %s." % self["revision_list"] | 196 title = "Revert %s." % self["revision_list"] |
| 212 else: | 197 else: |
| 213 title = ("Version %s (merged %s)" | 198 title = ("Version %s (merged %s)" |
| 214 % (self["version"], self["revision_list"])) | 199 % (self["version"], self["revision_list"])) |
| 215 self["new_commit_msg"] = "%s\n\n%s" % (title, self["new_commit_msg"]) | 200 self["new_commit_msg"] = "%s\n\n%s" % (title, self["new_commit_msg"]) |
| 216 TextToFile(self["new_commit_msg"], self.Config(COMMITMSG_FILE)) | 201 TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE")) |
| 217 self.GitCommit(file_name=self.Config(COMMITMSG_FILE)) | 202 self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) |
| 218 | 203 |
| 219 | 204 |
| 220 class CommitRepository(Step): | 205 class CommitRepository(Step): |
| 221 MESSAGE = "Commit to the repository." | 206 MESSAGE = "Commit to the repository." |
| 222 | 207 |
| 223 def RunStep(self): | 208 def RunStep(self): |
| 224 self.GitCheckout(self.Config(BRANCHNAME)) | 209 self.GitCheckout(self.Config("BRANCHNAME")) |
| 225 self.WaitForLGTM() | 210 self.WaitForLGTM() |
| 226 self.GitPresubmit() | 211 self.GitPresubmit() |
| 227 self.GitDCommit() | 212 self.GitDCommit() |
| 228 | 213 |
| 229 | 214 |
| 230 class PrepareSVN(Step): | 215 class PrepareSVN(Step): |
| 231 MESSAGE = "Determine svn commit revision." | 216 MESSAGE = "Determine svn commit revision." |
| 232 | 217 |
| 233 def RunStep(self): | 218 def RunStep(self): |
| 234 if self._options.revert_bleeding_edge: | 219 if self._options.revert_bleeding_edge: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 if len(options.revisions) < 1: | 288 if len(options.revisions) < 1: |
| 304 if not options.patch: | 289 if not options.patch: |
| 305 print "Either a patch file or revision numbers must be specified" | 290 print "Either a patch file or revision numbers must be specified" |
| 306 return False | 291 return False |
| 307 if not options.message: | 292 if not options.message: |
| 308 print "You must specify a merge comment if no patches are specified" | 293 print "You must specify a merge comment if no patches are specified" |
| 309 return False | 294 return False |
| 310 options.bypass_upload_hooks = True | 295 options.bypass_upload_hooks = True |
| 311 return True | 296 return True |
| 312 | 297 |
| 298 def _Config(self): |
| 299 return { |
| 300 "BRANCHNAME": "prepare-merge", |
| 301 "PERSISTFILE_BASENAME": "/tmp/v8-merge-to-branch-tempfile", |
| 302 "ALREADY_MERGING_SENTINEL_FILE": |
| 303 "/tmp/v8-merge-to-branch-tempfile-already-merging", |
| 304 "TEMPORARY_PATCH_FILE": "/tmp/v8-prepare-merge-tempfile-temporary-patch", |
| 305 "COMMITMSG_FILE": "/tmp/v8-prepare-merge-tempfile-commitmsg", |
| 306 } |
| 307 |
| 313 def _Steps(self): | 308 def _Steps(self): |
| 314 return [ | 309 return [ |
| 315 Preparation, | 310 Preparation, |
| 316 CreateBranch, | 311 CreateBranch, |
| 317 SearchArchitecturePorts, | 312 SearchArchitecturePorts, |
| 318 FindGitRevisions, | 313 FindGitRevisions, |
| 319 ApplyPatches, | 314 ApplyPatches, |
| 320 PrepareVersion, | 315 PrepareVersion, |
| 321 IncrementVersion, | 316 IncrementVersion, |
| 322 CommitLocal, | 317 CommitLocal, |
| 323 UploadStep, | 318 UploadStep, |
| 324 CommitRepository, | 319 CommitRepository, |
| 325 PrepareSVN, | 320 PrepareSVN, |
| 326 TagRevision, | 321 TagRevision, |
| 327 CleanUp, | 322 CleanUp, |
| 328 ] | 323 ] |
| 329 | 324 |
| 330 | 325 |
| 331 if __name__ == "__main__": # pragma: no cover | 326 if __name__ == "__main__": # pragma: no cover |
| 332 sys.exit(MergeToBranch(CONFIG).Run()) | 327 sys.exit(MergeToBranch().Run()) |
| OLD | NEW |