| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 # TODO(machenbach): last_push_trunk points to the svn revision on trunk. | 104 # TODO(machenbach): last_push_trunk points to the svn revision on trunk. |
| 105 # It is not used yet but we'll need it for retrieving the current version. | 105 # It is not used yet but we'll need it for retrieving the current version. |
| 106 self["last_push_trunk"] = last_push | 106 self["last_push_trunk"] = last_push |
| 107 # TODO(machenbach): This currently points to the prepare push revision that | 107 # TODO(machenbach): This currently points to the prepare push revision that |
| 108 # will be deprecated soon. After the deprecation it will point to the last | 108 # will be deprecated soon. After the deprecation it will point to the last |
| 109 # bleeding_edge revision that went into the last push. | 109 # bleeding_edge revision that went into the last push. |
| 110 self["last_push_bleeding_edge"] = last_push_bleeding_edge | 110 self["last_push_bleeding_edge"] = last_push_bleeding_edge |
| 111 | 111 |
| 112 | 112 |
| 113 class IncrementVersion(Step): |
| 114 MESSAGE = "Increment version number." |
| 115 |
| 116 def RunStep(self): |
| 117 # Retrieve current version from last trunk push. |
| 118 self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"]) |
| 119 self.ReadAndPersistVersion() |
| 120 |
| 121 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " |
| 122 "fire up your EDITOR on %s so you can make arbitrary " |
| 123 "changes. When you're done, save the file and exit your " |
| 124 "EDITOR.)" % self.Config(VERSION_FILE))): |
| 125 text = FileToText(self.Config(VERSION_FILE)) |
| 126 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 127 r"\g<space>%s" % str(int(self["build"]) + 1), |
| 128 text) |
| 129 TextToFile(text, self.Config(VERSION_FILE)) |
| 130 else: |
| 131 self.Editor(self.Config(VERSION_FILE)) |
| 132 |
| 133 # Variables prefixed with 'new_' contain the new version numbers for the |
| 134 # ongoing trunk push. |
| 135 self.ReadAndPersistVersion("new_") |
| 136 self["version"] = "%s.%s.%s" % (self["new_major"], |
| 137 self["new_minor"], |
| 138 self["new_build"]) |
| 139 |
| 140 # TODO(machenbach): The following will be deprecated. Increment version |
| 141 # numbers for version.cc on bleeding_edge (new build level on trunk + 1). |
| 142 text = FileToText(self.Config(VERSION_FILE)) |
| 143 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 144 r"\g<space>%s" % str(int(self["new_build"]) + 1), |
| 145 text) |
| 146 TextToFile(text, self.Config(VERSION_FILE)) |
| 147 self.ReadAndPersistVersion("new_be_") |
| 148 |
| 149 |
| 113 class PrepareChangeLog(Step): | 150 class PrepareChangeLog(Step): |
| 114 MESSAGE = "Prepare raw ChangeLog entry." | 151 MESSAGE = "Prepare raw ChangeLog entry." |
| 115 | 152 |
| 116 def Reload(self, body): | 153 def Reload(self, body): |
| 117 """Attempts to reload the commit message from rietveld in order to allow | 154 """Attempts to reload the commit message from rietveld in order to allow |
| 118 late changes to the LOG flag. Note: This is brittle to future changes of | 155 late changes to the LOG flag. Note: This is brittle to future changes of |
| 119 the web page name or structure. | 156 the web page name or structure. |
| 120 """ | 157 """ |
| 121 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", | 158 match = re.search(r"^Review URL: https://codereview\.chromium\.org/(\d+)$", |
| 122 body, flags=re.M) | 159 body, flags=re.M) |
| 123 if match: | 160 if match: |
| 124 cl_url = ("https://codereview.chromium.org/%s/description" | 161 cl_url = ("https://codereview.chromium.org/%s/description" |
| 125 % match.group(1)) | 162 % match.group(1)) |
| 126 try: | 163 try: |
| 127 # Fetch from Rietveld but only retry once with one second delay since | 164 # Fetch from Rietveld but only retry once with one second delay since |
| 128 # there might be many revisions. | 165 # there might be many revisions. |
| 129 body = self.ReadURL(cl_url, wait_plan=[1]) | 166 body = self.ReadURL(cl_url, wait_plan=[1]) |
| 130 except urllib2.URLError: # pragma: no cover | 167 except urllib2.URLError: # pragma: no cover |
| 131 pass | 168 pass |
| 132 return body | 169 return body |
| 133 | 170 |
| 134 def RunStep(self): | 171 def RunStep(self): |
| 135 # These version numbers are used again later for the trunk commit. | |
| 136 self.ReadAndPersistVersion() | |
| 137 self["date"] = self.GetDate() | 172 self["date"] = self.GetDate() |
| 138 self["version"] = "%s.%s.%s" % (self["major"], | 173 output = "%s: Version %s\n\n" % (self["date"], self["version"]) |
| 139 self["minor"], | |
| 140 self["build"]) | |
| 141 output = "%s: Version %s\n\n" % (self["date"], | |
| 142 self["version"]) | |
| 143 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) | 174 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) |
| 144 commits = self.GitLog(format="%H", | 175 commits = self.GitLog(format="%H", |
| 145 git_hash="%s..HEAD" % self["last_push_bleeding_edge"]) | 176 git_hash="%s..HEAD" % self["last_push_bleeding_edge"]) |
| 146 | 177 |
| 147 # Cache raw commit messages. | 178 # Cache raw commit messages. |
| 148 commit_messages = [ | 179 commit_messages = [ |
| 149 [ | 180 [ |
| 150 self.GitLog(n=1, format="%s", git_hash=commit), | 181 self.GitLog(n=1, format="%s", git_hash=commit), |
| 151 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)), | 182 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)), |
| 152 self.GitLog(n=1, format="%an", git_hash=commit), | 183 self.GitLog(n=1, format="%an", git_hash=commit), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) | 215 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) |
| 185 changelog_entry = changelog_entry.lstrip() | 216 changelog_entry = changelog_entry.lstrip() |
| 186 | 217 |
| 187 if changelog_entry == "": # pragma: no cover | 218 if changelog_entry == "": # pragma: no cover |
| 188 self.Die("Empty ChangeLog entry.") | 219 self.Die("Empty ChangeLog entry.") |
| 189 | 220 |
| 190 # Safe new change log for adding it later to the trunk patch. | 221 # Safe new change log for adding it later to the trunk patch. |
| 191 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) | 222 TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) |
| 192 | 223 |
| 193 | 224 |
| 194 class IncrementVersion(Step): | |
| 195 MESSAGE = "Increment version number." | |
| 196 | |
| 197 def RunStep(self): | |
| 198 new_build = str(int(self["build"]) + 1) | |
| 199 | |
| 200 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " | |
| 201 "fire up your EDITOR on %s so you can make arbitrary " | |
| 202 "changes. When you're done, save the file and exit your " | |
| 203 "EDITOR.)" % self.Config(VERSION_FILE))): | |
| 204 text = FileToText(self.Config(VERSION_FILE)) | |
| 205 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | |
| 206 r"\g<space>%s" % new_build, | |
| 207 text) | |
| 208 TextToFile(text, self.Config(VERSION_FILE)) | |
| 209 else: | |
| 210 self.Editor(self.Config(VERSION_FILE)) | |
| 211 | |
| 212 self.ReadAndPersistVersion("new_") | |
| 213 | |
| 214 | |
| 215 class CommitLocal(Step): | 225 class CommitLocal(Step): |
| 216 MESSAGE = "Commit to local branch." | 226 MESSAGE = "Commit to local branch." |
| 217 | 227 |
| 218 def RunStep(self): | 228 def RunStep(self): |
| 219 self["prep_commit_msg"] = ("Prepare push to trunk. " | 229 self["prep_commit_msg"] = ("Prepare push to trunk. " |
| 220 "Now working on version %s.%s.%s." % (self["new_major"], | 230 "Now working on version %s.%s.%s." % (self["new_be_major"], |
| 221 self["new_minor"], | 231 self["new_be_minor"], |
| 222 self["new_build"])) | 232 self["new_be_build"])) |
| 223 | 233 |
| 224 # Include optional TBR only in the git command. The persisted commit | 234 # Include optional TBR only in the git command. The persisted commit |
| 225 # message is used for finding the commit again later. | 235 # message is used for finding the commit again later. |
| 226 if self._options.tbr_commit: | 236 if self._options.tbr_commit: |
| 227 message = "%s\n\nTBR=%s" % (self["prep_commit_msg"], | 237 message = "%s\n\nTBR=%s" % (self["prep_commit_msg"], |
| 228 self._options.reviewer) | 238 self._options.reviewer) |
| 229 else: | 239 else: |
| 230 message = "%s" % self["prep_commit_msg"] | 240 message = "%s" % self["prep_commit_msg"] |
| 231 self.GitCommit(message) | 241 self.GitCommit(message) |
| 232 | 242 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 class SetVersion(Step): | 332 class SetVersion(Step): |
| 323 MESSAGE = "Set correct version for trunk." | 333 MESSAGE = "Set correct version for trunk." |
| 324 | 334 |
| 325 def RunStep(self): | 335 def RunStep(self): |
| 326 # The version file has been modified by the patch. Reset it to the version | 336 # The version file has been modified by the patch. Reset it to the version |
| 327 # on trunk and apply the correct version. | 337 # on trunk and apply the correct version. |
| 328 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/trunk") | 338 self.GitCheckoutFile(self.Config(VERSION_FILE), "svn/trunk") |
| 329 output = "" | 339 output = "" |
| 330 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): | 340 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): |
| 331 if line.startswith("#define MAJOR_VERSION"): | 341 if line.startswith("#define MAJOR_VERSION"): |
| 332 line = re.sub("\d+$", self["major"], line) | 342 line = re.sub("\d+$", self["new_major"], line) |
| 333 elif line.startswith("#define MINOR_VERSION"): | 343 elif line.startswith("#define MINOR_VERSION"): |
| 334 line = re.sub("\d+$", self["minor"], line) | 344 line = re.sub("\d+$", self["new_minor"], line) |
| 335 elif line.startswith("#define BUILD_NUMBER"): | 345 elif line.startswith("#define BUILD_NUMBER"): |
| 336 line = re.sub("\d+$", self["build"], line) | 346 line = re.sub("\d+$", self["new_build"], line) |
| 337 elif line.startswith("#define PATCH_LEVEL"): | 347 elif line.startswith("#define PATCH_LEVEL"): |
| 338 line = re.sub("\d+$", "0", line) | 348 line = re.sub("\d+$", "0", line) |
| 339 elif line.startswith("#define IS_CANDIDATE_VERSION"): | 349 elif line.startswith("#define IS_CANDIDATE_VERSION"): |
| 340 line = re.sub("\d+$", "0", line) | 350 line = re.sub("\d+$", "0", line) |
| 341 output += "%s\n" % line | 351 output += "%s\n" % line |
| 342 TextToFile(output, self.Config(VERSION_FILE)) | 352 TextToFile(output, self.Config(VERSION_FILE)) |
| 343 | 353 |
| 344 | 354 |
| 345 class CommitTrunk(Step): | 355 class CommitTrunk(Step): |
| 346 MESSAGE = "Commit to local trunk branch." | 356 MESSAGE = "Commit to local trunk branch." |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 return False | 532 return False |
| 523 | 533 |
| 524 options.tbr_commit = not options.manual | 534 options.tbr_commit = not options.manual |
| 525 return True | 535 return True |
| 526 | 536 |
| 527 def _Steps(self): | 537 def _Steps(self): |
| 528 return [ | 538 return [ |
| 529 Preparation, | 539 Preparation, |
| 530 FreshBranch, | 540 FreshBranch, |
| 531 DetectLastPush, | 541 DetectLastPush, |
| 542 IncrementVersion, |
| 532 PrepareChangeLog, | 543 PrepareChangeLog, |
| 533 EditChangeLog, | 544 EditChangeLog, |
| 534 IncrementVersion, | |
| 535 CommitLocal, | 545 CommitLocal, |
| 536 UploadStep, | 546 UploadStep, |
| 537 CommitRepository, | 547 CommitRepository, |
| 538 StragglerCommits, | 548 StragglerCommits, |
| 539 SquashCommits, | 549 SquashCommits, |
| 540 NewBranch, | 550 NewBranch, |
| 541 ApplyChanges, | 551 ApplyChanges, |
| 542 AddChangeLog, | 552 AddChangeLog, |
| 543 SetVersion, | 553 SetVersion, |
| 544 CommitTrunk, | 554 CommitTrunk, |
| 545 SanityCheck, | 555 SanityCheck, |
| 546 CommitSVN, | 556 CommitSVN, |
| 547 TagRevision, | 557 TagRevision, |
| 548 CheckChromium, | 558 CheckChromium, |
| 549 SwitchChromium, | 559 SwitchChromium, |
| 550 UpdateChromiumCheckout, | 560 UpdateChromiumCheckout, |
| 551 UploadCL, | 561 UploadCL, |
| 552 SwitchV8, | 562 SwitchV8, |
| 553 CleanUp, | 563 CleanUp, |
| 554 ] | 564 ] |
| 555 | 565 |
| 556 | 566 |
| 557 if __name__ == "__main__": # pragma: no cover | 567 if __name__ == "__main__": # pragma: no cover |
| 558 sys.exit(PushToTrunk(CONFIG).Run()) | 568 sys.exit(PushToTrunk(CONFIG).Run()) |
| OLD | NEW |