| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 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 22 matching lines...) Expand all Loading... |
| 33 import urllib2 | 33 import urllib2 |
| 34 | 34 |
| 35 from common_includes import * | 35 from common_includes import * |
| 36 | 36 |
| 37 TRUNKBRANCH = "TRUNKBRANCH" | 37 TRUNKBRANCH = "TRUNKBRANCH" |
| 38 | 38 |
| 39 CONFIG = { | 39 CONFIG = { |
| 40 BRANCHNAME: "prepare-push", | 40 BRANCHNAME: "prepare-push", |
| 41 TRUNKBRANCH: "trunk-push", | 41 TRUNKBRANCH: "trunk-push", |
| 42 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", | 42 PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", |
| 43 VERSION_FILE: "src/version.cc", | |
| 44 CHANGELOG_FILE: "ChangeLog", | 43 CHANGELOG_FILE: "ChangeLog", |
| 45 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", | 44 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", |
| 46 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", | 45 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", |
| 47 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", | 46 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", |
| 48 } | 47 } |
| 49 | 48 |
| 50 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" | 49 PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" |
| 51 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") | 50 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") |
| 52 | 51 |
| 53 | |
| 54 class Preparation(Step): | 52 class Preparation(Step): |
| 55 MESSAGE = "Preparation." | 53 MESSAGE = "Preparation." |
| 56 | 54 |
| 57 def RunStep(self): | 55 def RunStep(self): |
| 58 self.InitialEnvironmentChecks(self.default_cwd) | 56 self.InitialEnvironmentChecks(self.default_cwd) |
| 59 self.CommonPrepare() | 57 self.CommonPrepare() |
| 60 | 58 |
| 61 if(self["current_branch"] == self.Config(TRUNKBRANCH) | 59 if(self["current_branch"] == self.Config(TRUNKBRANCH) |
| 62 or self["current_branch"] == self.Config(BRANCHNAME)): | 60 or self["current_branch"] == self.Config(BRANCHNAME)): |
| 63 print "Warning: Script started on branch %s" % self["current_branch"] | 61 print "Warning: Script started on branch %s" % self["current_branch"] |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 # current change log preparation won't make much sense. | 121 # current change log preparation won't make much sense. |
| 124 self["last_push_bleeding_edge"] = last_push_bleeding_edge | 122 self["last_push_bleeding_edge"] = last_push_bleeding_edge |
| 125 | 123 |
| 126 | 124 |
| 127 # TODO(machenbach): Code similarities with bump_up_version.py. Merge after | 125 # TODO(machenbach): Code similarities with bump_up_version.py. Merge after |
| 128 # turning this script into a pure git script. | 126 # turning this script into a pure git script. |
| 129 class GetCurrentBleedingEdgeVersion(Step): | 127 class GetCurrentBleedingEdgeVersion(Step): |
| 130 MESSAGE = "Get latest bleeding edge version." | 128 MESSAGE = "Get latest bleeding edge version." |
| 131 | 129 |
| 132 def RunStep(self): | 130 def RunStep(self): |
| 133 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/bleeding_edge") | 131 self.GitCheckoutFile(VERSION_FILE, "svn/bleeding_edge") |
| 134 | 132 |
| 135 # Store latest version. | 133 # Store latest version. |
| 136 self.ReadAndPersistVersion("latest_") | 134 self.ReadAndPersistVersion("latest_") |
| 137 self["latest_version"] = self.ArrayToVersion("latest_") | 135 self["latest_version"] = self.ArrayToVersion("latest_") |
| 138 print "Bleeding edge version: %s" % self["latest_version"] | 136 print "Bleeding edge version: %s" % self["latest_version"] |
| 139 | 137 |
| 140 | 138 |
| 141 class IncrementVersion(Step): | 139 class IncrementVersion(Step): |
| 142 MESSAGE = "Increment version number." | 140 MESSAGE = "Increment version number." |
| 143 | 141 |
| 144 def RunStep(self): | 142 def RunStep(self): |
| 145 # Retrieve current version from last trunk push. | 143 # Retrieve current version from last trunk push. |
| 146 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) | 144 self.GitCheckoutFile(VERSION_FILE, self["last_push_trunk"]) |
| 147 self.ReadAndPersistVersion() | 145 self.ReadAndPersistVersion() |
| 148 self["trunk_version"] = self.ArrayToVersion("") | 146 self["trunk_version"] = self.ArrayToVersion("") |
| 149 | 147 |
| 150 if self["latest_build"] == "9999": # pragma: no cover | 148 if self["latest_build"] == "9999": # pragma: no cover |
| 151 # If version control on bleeding edge was switched off, just use the last | 149 # If version control on bleeding edge was switched off, just use the last |
| 152 # trunk version. | 150 # trunk version. |
| 153 self["latest_version"] = self["trunk_version"] | 151 self["latest_version"] = self["trunk_version"] |
| 154 | 152 |
| 155 if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]): | 153 if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]): |
| 156 # If the version on bleeding_edge is newer than on trunk, use it. | 154 # If the version on bleeding_edge is newer than on trunk, use it. |
| 157 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/bleeding_edge") | 155 self.GitCheckoutFile(VERSION_FILE, "svn/bleeding_edge") |
| 158 self.ReadAndPersistVersion() | 156 self.ReadAndPersistVersion() |
| 159 | 157 |
| 160 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " | 158 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " |
| 161 "fire up your EDITOR on %s so you can make arbitrary " | 159 "fire up your EDITOR on %s so you can make arbitrary " |
| 162 "changes. When you're done, save the file and exit your " | 160 "changes. When you're done, save the file and exit your " |
| 163 "EDITOR.)" % self.Config(VERSION_FILE))): | 161 "EDITOR.)" % VERSION_FILE)): |
| 164 | 162 |
| 165 text = FileToText(self.Config(VERSION_FILE)) | 163 text = FileToText(os.path.join(self.default_cwd, VERSION_FILE)) |
| 166 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 164 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 167 r"\g<space>%s" % str(int(self["build"]) + 1), | 165 r"\g<space>%s" % str(int(self["build"]) + 1), |
| 168 text) | 166 text) |
| 169 TextToFile(text, self.Config(VERSION_FILE)) | 167 TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE)) |
| 170 else: | 168 else: |
| 171 self.Editor(self.Config(VERSION_FILE)) | 169 self.Editor(os.path.join(self.default_cwd, VERSION_FILE)) |
| 172 | 170 |
| 173 # Variables prefixed with 'new_' contain the new version numbers for the | 171 # Variables prefixed with 'new_' contain the new version numbers for the |
| 174 # ongoing trunk push. | 172 # ongoing trunk push. |
| 175 self.ReadAndPersistVersion("new_") | 173 self.ReadAndPersistVersion("new_") |
| 176 | 174 |
| 177 # Make sure patch level is 0 in a new push. | 175 # Make sure patch level is 0 in a new push. |
| 178 self["new_patch"] = "0" | 176 self["new_patch"] = "0" |
| 179 | 177 |
| 180 self["version"] = "%s.%s.%s" % (self["new_major"], | 178 self["version"] = "%s.%s.%s" % (self["new_major"], |
| 181 self["new_minor"], | 179 self["new_minor"], |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) | 327 TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) |
| 330 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) | 328 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) |
| 331 | 329 |
| 332 | 330 |
| 333 class SetVersion(Step): | 331 class SetVersion(Step): |
| 334 MESSAGE = "Set correct version for trunk." | 332 MESSAGE = "Set correct version for trunk." |
| 335 | 333 |
| 336 def RunStep(self): | 334 def RunStep(self): |
| 337 # The version file has been modified by the patch. Reset it to the version | 335 # The version file has been modified by the patch. Reset it to the version |
| 338 # on trunk and apply the correct version. | 336 # on trunk and apply the correct version. |
| 339 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/trunk") | 337 self.GitCheckoutFile(VERSION_FILE, "svn/trunk") |
| 340 self.SetVersion(self.Config(VERSION_FILE), "new_") | 338 self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_") |
| 341 | 339 |
| 342 | 340 |
| 343 class CommitTrunk(Step): | 341 class CommitTrunk(Step): |
| 344 MESSAGE = "Commit to local trunk branch." | 342 MESSAGE = "Commit to local trunk branch." |
| 345 | 343 |
| 346 def RunStep(self): | 344 def RunStep(self): |
| 347 self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) | 345 self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) |
| 348 os.remove(self.Config(COMMITMSG_FILE)) | 346 os.remove(self.Config(COMMITMSG_FILE)) |
| 349 | 347 |
| 350 | 348 |
| 351 class SanityCheck(Step): | 349 class SanityCheck(Step): |
| 352 MESSAGE = "Sanity check." | 350 MESSAGE = "Sanity check." |
| 353 | 351 |
| 354 def RunStep(self): | 352 def RunStep(self): |
| 355 # TODO(machenbach): Run presubmit script here as it is now missing in the | 353 # TODO(machenbach): Run presubmit script here as it is now missing in the |
| 356 # prepare push process. | 354 # prepare push process. |
| 357 if not self.Confirm("Please check if your local checkout is sane: Inspect " | 355 if not self.Confirm("Please check if your local checkout is sane: Inspect " |
| 358 "%s, compile, run tests. Do you want to commit this new trunk " | 356 "%s, compile, run tests. Do you want to commit this new trunk " |
| 359 "revision to the repository?" % self.Config(VERSION_FILE)): | 357 "revision to the repository?" % VERSION_FILE): |
| 360 self.Die("Execution canceled.") # pragma: no cover | 358 self.Die("Execution canceled.") # pragma: no cover |
| 361 | 359 |
| 362 | 360 |
| 363 class CommitSVN(Step): | 361 class CommitSVN(Step): |
| 364 MESSAGE = "Commit to SVN." | 362 MESSAGE = "Commit to SVN." |
| 365 | 363 |
| 366 def RunStep(self): | 364 def RunStep(self): |
| 367 result = self.GitSVNDCommit() | 365 result = self.GitSVNDCommit() |
| 368 if not result: # pragma: no cover | 366 if not result: # pragma: no cover |
| 369 self.Die("'git svn dcommit' failed.") | 367 self.Die("'git svn dcommit' failed.") |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 CommitTrunk, | 456 CommitTrunk, |
| 459 SanityCheck, | 457 SanityCheck, |
| 460 CommitSVN, | 458 CommitSVN, |
| 461 TagRevision, | 459 TagRevision, |
| 462 CleanUp, | 460 CleanUp, |
| 463 ] | 461 ] |
| 464 | 462 |
| 465 | 463 |
| 466 if __name__ == "__main__": # pragma: no cover | 464 if __name__ == "__main__": # pragma: no cover |
| 467 sys.exit(PushToTrunk(CONFIG).Run()) | 465 sys.exit(PushToTrunk(CONFIG).Run()) |
| OLD | NEW |