| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 self.InitialEnvironmentChecks() | 91 self.InitialEnvironmentChecks() |
| 92 self.CommonPrepare() | 92 self.CommonPrepare() |
| 93 self.PrepareBranch() | 93 self.PrepareBranch() |
| 94 self.DeleteBranch(self.Config(TRUNKBRANCH)) | 94 self.DeleteBranch(self.Config(TRUNKBRANCH)) |
| 95 | 95 |
| 96 | 96 |
| 97 class FreshBranch(Step): | 97 class FreshBranch(Step): |
| 98 MESSAGE = "Create a fresh branch." | 98 MESSAGE = "Create a fresh branch." |
| 99 | 99 |
| 100 def RunStep(self): | 100 def RunStep(self): |
| 101 args = "checkout -b %s svn/bleeding_edge" % self.Config(BRANCHNAME) | 101 self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") |
| 102 self.Git(args) | |
| 103 | 102 |
| 104 | 103 |
| 105 class DetectLastPush(Step): | 104 class DetectLastPush(Step): |
| 106 MESSAGE = "Detect commit ID of last push to trunk." | 105 MESSAGE = "Detect commit ID of last push to trunk." |
| 107 | 106 |
| 108 def RunStep(self): | 107 def RunStep(self): |
| 109 last_push_trunk = self._options.l or self.FindLastTrunkPush() | 108 last_push = self._options.l or self.FindLastTrunkPush() |
| 110 while True: | 109 while True: |
| 111 # Print assumed commit, circumventing git's pager. | 110 # Print assumed commit, circumventing git's pager. |
| 112 print self.Git("log -1 %s" % last_push_trunk) | 111 print self.GitLog(n=1, git_hash=last_push) |
| 113 if self.Confirm("Is the commit printed above the last push to trunk?"): | 112 if self.Confirm("Is the commit printed above the last push to trunk?"): |
| 114 break | 113 break |
| 115 args = ("log -1 --format=%%H %s^ --grep=\"%s\"" | 114 last_push = self.FindLastTrunkPush(parent_hash=last_push) |
| 116 % (last_push_trunk, push_pattern)) | |
| 117 last_push_trunk = self.Git(args).strip() | |
| 118 | 115 |
| 119 if self._options.b: | 116 if self._options.b: |
| 120 # Read the bleeding edge revision of the last push from a command-line | 117 # Read the bleeding edge revision of the last push from a command-line |
| 121 # option. | 118 # option. |
| 122 last_push_bleeding_edge = self._options.b | 119 last_push_bleeding_edge = self._options.b |
| 123 else: | 120 else: |
| 124 # Retrieve the bleeding edge revision of the last push from the text in | 121 # Retrieve the bleeding edge revision of the last push from the text in |
| 125 # the push commit message. | 122 # the push commit message. |
| 126 args = "log -1 --format=%%s %s" % last_push_trunk | 123 last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push) |
| 127 last_push_trunk_title = self.Git(args).strip() | 124 last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1) |
| 128 last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_trunk_title).group(1) | |
| 129 if not last_push_be_svn: | 125 if not last_push_be_svn: |
| 130 self.Die("Could not retrieve bleeding edge revision for trunk push %s" | 126 self.Die("Could not retrieve bleeding edge revision for trunk push %s" |
| 131 % last_push_trunk) | 127 % last_push) |
| 132 args = "svn find-rev r%s" % last_push_be_svn | 128 last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn) |
| 133 last_push_bleeding_edge = self.Git(args).strip() | |
| 134 if not last_push_bleeding_edge: | 129 if not last_push_bleeding_edge: |
| 135 self.Die("Could not retrieve bleeding edge git hash for trunk push %s" | 130 self.Die("Could not retrieve bleeding edge git hash for trunk push %s" |
| 136 % last_push_trunk) | 131 % last_push) |
| 137 | 132 |
| 138 # TODO(machenbach): last_push_trunk points to the svn revision on trunk. | 133 # TODO(machenbach): last_push_trunk points to the svn revision on trunk. |
| 139 # It is not used yet but we'll need it for retrieving the current version. | 134 # It is not used yet but we'll need it for retrieving the current version. |
| 140 self["last_push_trunk"] = last_push_trunk | 135 self["last_push_trunk"] = last_push |
| 141 # TODO(machenbach): This currently points to the prepare push revision that | 136 # TODO(machenbach): This currently points to the prepare push revision that |
| 142 # will be deprecated soon. After the deprecation it will point to the last | 137 # will be deprecated soon. After the deprecation it will point to the last |
| 143 # bleeding_edge revision that went into the last push. | 138 # bleeding_edge revision that went into the last push. |
| 144 self["last_push_bleeding_edge"] = last_push_bleeding_edge | 139 self["last_push_bleeding_edge"] = last_push_bleeding_edge |
| 145 | 140 |
| 146 | 141 |
| 147 class PrepareChangeLog(Step): | 142 class PrepareChangeLog(Step): |
| 148 MESSAGE = "Prepare raw ChangeLog entry." | 143 MESSAGE = "Prepare raw ChangeLog entry." |
| 149 | 144 |
| 150 def Reload(self, body): | 145 def Reload(self, body): |
| (...skipping 17 matching lines...) Expand all Loading... |
| 168 def RunStep(self): | 163 def RunStep(self): |
| 169 # These version numbers are used again later for the trunk commit. | 164 # These version numbers are used again later for the trunk commit. |
| 170 self.ReadAndPersistVersion() | 165 self.ReadAndPersistVersion() |
| 171 self["date"] = self.GetDate() | 166 self["date"] = self.GetDate() |
| 172 self["version"] = "%s.%s.%s" % (self["major"], | 167 self["version"] = "%s.%s.%s" % (self["major"], |
| 173 self["minor"], | 168 self["minor"], |
| 174 self["build"]) | 169 self["build"]) |
| 175 output = "%s: Version %s\n\n" % (self["date"], | 170 output = "%s: Version %s\n\n" % (self["date"], |
| 176 self["version"]) | 171 self["version"]) |
| 177 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) | 172 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) |
| 178 | 173 commits = self.GitLog(format="%H", |
| 179 args = "log %s..HEAD --format=%%H" % self["last_push_bleeding_edge"] | 174 git_hash="%s..HEAD" % self["last_push_bleeding_edge"]) |
| 180 commits = self.Git(args).strip() | |
| 181 | 175 |
| 182 # Cache raw commit messages. | 176 # Cache raw commit messages. |
| 183 commit_messages = [ | 177 commit_messages = [ |
| 184 [ | 178 [ |
| 185 self.Git("log -1 %s --format=\"%%s\"" % commit), | 179 self.GitLog(n=1, format="%s", git_hash=commit), |
| 186 self.Reload(self.Git("log -1 %s --format=\"%%B\"" % commit)), | 180 self.Reload(self.GitLog(n=1, format="%B", git_hash=commit)), |
| 187 self.Git("log -1 %s --format=\"%%an\"" % commit), | 181 self.GitLog(n=1, format="%an", git_hash=commit), |
| 188 ] for commit in commits.splitlines() | 182 ] for commit in commits.splitlines() |
| 189 ] | 183 ] |
| 190 | 184 |
| 191 # Auto-format commit messages. | 185 # Auto-format commit messages. |
| 192 body = MakeChangeLogBody(commit_messages, auto_format=True) | 186 body = MakeChangeLogBody(commit_messages, auto_format=True) |
| 193 AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) | 187 AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) |
| 194 | 188 |
| 195 msg = (" Performance and stability improvements on all platforms." | 189 msg = (" Performance and stability improvements on all platforms." |
| 196 "\n#\n# The change log above is auto-generated. Please review if " | 190 "\n#\n# The change log above is auto-generated. Please review if " |
| 197 "all relevant\n# commit messages from the list below are included." | 191 "all relevant\n# commit messages from the list below are included." |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 253 |
| 260 def RunStep(self): | 254 def RunStep(self): |
| 261 self["prep_commit_msg"] = ("Prepare push to trunk. " | 255 self["prep_commit_msg"] = ("Prepare push to trunk. " |
| 262 "Now working on version %s.%s.%s." % (self["new_major"], | 256 "Now working on version %s.%s.%s." % (self["new_major"], |
| 263 self["new_minor"], | 257 self["new_minor"], |
| 264 self["new_build"])) | 258 self["new_build"])) |
| 265 | 259 |
| 266 # Include optional TBR only in the git command. The persisted commit | 260 # Include optional TBR only in the git command. The persisted commit |
| 267 # message is used for finding the commit again later. | 261 # message is used for finding the commit again later. |
| 268 if self._options.tbr_commit: | 262 if self._options.tbr_commit: |
| 269 review = "\n\nTBR=%s" % self._options.reviewer | 263 message = "%s\n\nTBR=%s" % (self["prep_commit_msg"], |
| 264 self._options.reviewer) |
| 270 else: | 265 else: |
| 271 review = "" | 266 message = "%s" % self["prep_commit_msg"] |
| 272 self.Git("commit -a -m \"%s%s\"" % (self["prep_commit_msg"], review)) | 267 self.GitCommit(message) |
| 273 | 268 |
| 274 | 269 |
| 275 class CommitRepository(Step): | 270 class CommitRepository(Step): |
| 276 MESSAGE = "Commit to the repository." | 271 MESSAGE = "Commit to the repository." |
| 277 | 272 |
| 278 def RunStep(self): | 273 def RunStep(self): |
| 279 self.WaitForLGTM() | 274 self.WaitForLGTM() |
| 280 # Re-read the ChangeLog entry (to pick up possible changes). | 275 # Re-read the ChangeLog entry (to pick up possible changes). |
| 281 # FIXME(machenbach): This was hanging once with a broken pipe. | 276 # FIXME(machenbach): This was hanging once with a broken pipe. |
| 282 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)), | 277 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)), |
| 283 self.Config(CHANGELOG_ENTRY_FILE)) | 278 self.Config(CHANGELOG_ENTRY_FILE)) |
| 284 | 279 |
| 285 self.Git("cl presubmit", "PRESUBMIT_TREE_CHECK=\"skip\"") | 280 self.GitPresubmit() |
| 286 self.Git("cl dcommit -f --bypass-hooks", retry_on=lambda x: x is None) | 281 self.GitDCommit() |
| 287 | 282 |
| 288 | 283 |
| 289 class StragglerCommits(Step): | 284 class StragglerCommits(Step): |
| 290 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " | 285 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " |
| 291 "started.") | 286 "started.") |
| 292 | 287 |
| 293 def RunStep(self): | 288 def RunStep(self): |
| 294 self.Git("svn fetch") | 289 self.GitSVNFetch() |
| 295 self.Git("checkout svn/bleeding_edge") | 290 self.GitCheckout("svn/bleeding_edge") |
| 296 args = "log -1 --format=%%H --grep=\"%s\"" % self["prep_commit_msg"] | 291 self["prepare_commit_hash"] = self.GitLog(n=1, format="%H", |
| 297 self["prepare_commit_hash"] = self.Git(args).strip() | 292 grep=self["prep_commit_msg"]) |
| 298 | 293 |
| 299 | 294 |
| 300 class SquashCommits(Step): | 295 class SquashCommits(Step): |
| 301 MESSAGE = "Squash commits into one." | 296 MESSAGE = "Squash commits into one." |
| 302 | 297 |
| 303 def RunStep(self): | 298 def RunStep(self): |
| 304 # Instead of relying on "git rebase -i", we'll just create a diff, because | 299 # Instead of relying on "git rebase -i", we'll just create a diff, because |
| 305 # that's easier to automate. | 300 # that's easier to automate. |
| 306 args = "diff svn/trunk %s" % self["prepare_commit_hash"] | 301 TextToFile(self.GitDiff("svn/trunk", self["prepare_commit_hash"]), |
| 307 TextToFile(self.Git(args), self.Config(PATCH_FILE)) | 302 self.Config(PATCH_FILE)) |
| 308 | 303 |
| 309 # Convert the ChangeLog entry to commit message format. | 304 # Convert the ChangeLog entry to commit message format. |
| 310 text = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) | 305 text = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) |
| 311 | 306 |
| 312 # Remove date and trailing white space. | 307 # Remove date and trailing white space. |
| 313 text = re.sub(r"^%s: " % self["date"], "", text.rstrip()) | 308 text = re.sub(r"^%s: " % self["date"], "", text.rstrip()) |
| 314 | 309 |
| 315 # Retrieve svn revision for showing the used bleeding edge revision in the | 310 # Retrieve svn revision for showing the used bleeding edge revision in the |
| 316 # commit message. | 311 # commit message. |
| 317 args = "svn find-rev %s" % self["prepare_commit_hash"] | 312 self["svn_revision"] = self.GitSVNFindSVNRev(self["prepare_commit_hash"]) |
| 318 self["svn_revision"] = self.Git(args).strip() | |
| 319 suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"]) | 313 suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"]) |
| 320 text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text) | 314 text = MSub(r"^(Version \d+\.\d+\.\d+)$", "\\1%s" % suffix, text) |
| 321 | 315 |
| 322 # Remove indentation and merge paragraphs into single long lines, keeping | 316 # Remove indentation and merge paragraphs into single long lines, keeping |
| 323 # empty lines between them. | 317 # empty lines between them. |
| 324 def SplitMapJoin(split_text, fun, join_text): | 318 def SplitMapJoin(split_text, fun, join_text): |
| 325 return lambda text: join_text.join(map(fun, text.split(split_text))) | 319 return lambda text: join_text.join(map(fun, text.split(split_text))) |
| 326 strip = lambda line: line.strip() | 320 strip = lambda line: line.strip() |
| 327 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text) | 321 text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text) |
| 328 | 322 |
| 329 if not text: | 323 if not text: |
| 330 self.Die("Commit message editing failed.") | 324 self.Die("Commit message editing failed.") |
| 331 TextToFile(text, self.Config(COMMITMSG_FILE)) | 325 TextToFile(text, self.Config(COMMITMSG_FILE)) |
| 332 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) | 326 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) |
| 333 | 327 |
| 334 | 328 |
| 335 class NewBranch(Step): | 329 class NewBranch(Step): |
| 336 MESSAGE = "Create a new branch from trunk." | 330 MESSAGE = "Create a new branch from trunk." |
| 337 | 331 |
| 338 def RunStep(self): | 332 def RunStep(self): |
| 339 self.Git("checkout -b %s svn/trunk" % self.Config(TRUNKBRANCH)) | 333 self.GitCreateBranch(self.Config(TRUNKBRANCH), "svn/trunk") |
| 340 | 334 |
| 341 | 335 |
| 342 class ApplyChanges(Step): | 336 class ApplyChanges(Step): |
| 343 MESSAGE = "Apply squashed changes." | 337 MESSAGE = "Apply squashed changes." |
| 344 | 338 |
| 345 def RunStep(self): | 339 def RunStep(self): |
| 346 self.ApplyPatch(self.Config(PATCH_FILE)) | 340 self.ApplyPatch(self.Config(PATCH_FILE)) |
| 347 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) | 341 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) |
| 348 | 342 |
| 349 | 343 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 364 elif line.startswith("#define IS_CANDIDATE_VERSION"): | 358 elif line.startswith("#define IS_CANDIDATE_VERSION"): |
| 365 line = re.sub("\d+$", "0", line) | 359 line = re.sub("\d+$", "0", line) |
| 366 output += "%s\n" % line | 360 output += "%s\n" % line |
| 367 TextToFile(output, self.Config(VERSION_FILE)) | 361 TextToFile(output, self.Config(VERSION_FILE)) |
| 368 | 362 |
| 369 | 363 |
| 370 class CommitTrunk(Step): | 364 class CommitTrunk(Step): |
| 371 MESSAGE = "Commit to local trunk branch." | 365 MESSAGE = "Commit to local trunk branch." |
| 372 | 366 |
| 373 def RunStep(self): | 367 def RunStep(self): |
| 374 self.Git("add \"%s\"" % self.Config(VERSION_FILE)) | 368 self.GitAdd(self.Config(VERSION_FILE)) |
| 375 self.Git("commit -F \"%s\"" % self.Config(COMMITMSG_FILE)) | 369 self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) |
| 376 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) | 370 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) |
| 377 | 371 |
| 378 | 372 |
| 379 class SanityCheck(Step): | 373 class SanityCheck(Step): |
| 380 MESSAGE = "Sanity check." | 374 MESSAGE = "Sanity check." |
| 381 | 375 |
| 382 def RunStep(self): | 376 def RunStep(self): |
| 383 if not self.Confirm("Please check if your local checkout is sane: Inspect " | 377 if not self.Confirm("Please check if your local checkout is sane: Inspect " |
| 384 "%s, compile, run tests. Do you want to commit this new trunk " | 378 "%s, compile, run tests. Do you want to commit this new trunk " |
| 385 "revision to the repository?" % self.Config(VERSION_FILE)): | 379 "revision to the repository?" % self.Config(VERSION_FILE)): |
| 386 self.Die("Execution canceled.") | 380 self.Die("Execution canceled.") |
| 387 | 381 |
| 388 | 382 |
| 389 class CommitSVN(Step): | 383 class CommitSVN(Step): |
| 390 MESSAGE = "Commit to SVN." | 384 MESSAGE = "Commit to SVN." |
| 391 | 385 |
| 392 def RunStep(self): | 386 def RunStep(self): |
| 393 result = self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None) | 387 result = self.GitSVNDCommit() |
| 394 if not result: | 388 if not result: |
| 395 self.Die("'git svn dcommit' failed.") | 389 self.Die("'git svn dcommit' failed.") |
| 396 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x), | 390 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x), |
| 397 result.splitlines()) | 391 result.splitlines()) |
| 398 if len(result) > 0: | 392 if len(result) > 0: |
| 399 self["trunk_revision"] = re.sub(r"^Committed r([0-9]+)", r"\1",result[0]) | 393 self["trunk_revision"] = re.sub(r"^Committed r([0-9]+)", r"\1",result[0]) |
| 400 | 394 |
| 401 # Sometimes grepping for the revision fails. No idea why. If you figure | 395 # Sometimes grepping for the revision fails. No idea why. If you figure |
| 402 # out why it is flaky, please do fix it properly. | 396 # out why it is flaky, please do fix it properly. |
| 403 if not self["trunk_revision"]: | 397 if not self["trunk_revision"]: |
| 404 print("Sorry, grepping for the SVN revision failed. Please look for it " | 398 print("Sorry, grepping for the SVN revision failed. Please look for it " |
| 405 "in the last command's output above and provide it manually (just " | 399 "in the last command's output above and provide it manually (just " |
| 406 "the number, without the leading \"r\").") | 400 "the number, without the leading \"r\").") |
| 407 self.DieNoManualMode("Can't prompt in forced mode.") | 401 self.DieNoManualMode("Can't prompt in forced mode.") |
| 408 while not self["trunk_revision"]: | 402 while not self["trunk_revision"]: |
| 409 print "> ", | 403 print "> ", |
| 410 self["trunk_revision"] = self.ReadLine() | 404 self["trunk_revision"] = self.ReadLine() |
| 411 | 405 |
| 412 | 406 |
| 413 class TagRevision(Step): | 407 class TagRevision(Step): |
| 414 MESSAGE = "Tag the new revision." | 408 MESSAGE = "Tag the new revision." |
| 415 | 409 |
| 416 def RunStep(self): | 410 def RunStep(self): |
| 417 self.Git(("svn tag %s -m \"Tagging version %s\"" | 411 self.GitSVNTag(self["version"]) |
| 418 % (self["version"], self["version"])), | |
| 419 retry_on=lambda x: x is None) | |
| 420 | 412 |
| 421 | 413 |
| 422 class CheckChromium(Step): | 414 class CheckChromium(Step): |
| 423 MESSAGE = "Ask for chromium checkout." | 415 MESSAGE = "Ask for chromium checkout." |
| 424 | 416 |
| 425 def Run(self): | 417 def Run(self): |
| 426 self["chrome_path"] = self._options.c | 418 self["chrome_path"] = self._options.c |
| 427 if not self["chrome_path"]: | 419 if not self["chrome_path"]: |
| 428 self.DieNoManualMode("Please specify the path to a Chromium checkout in " | 420 self.DieNoManualMode("Please specify the path to a Chromium checkout in " |
| 429 "forced mode.") | 421 "forced mode.") |
| 430 print ("Do you have a \"NewGit\" Chromium checkout and want " | 422 print ("Do you have a \"NewGit\" Chromium checkout and want " |
| 431 "this script to automate creation of the roll CL? If yes, enter the " | 423 "this script to automate creation of the roll CL? If yes, enter the " |
| 432 "path to (and including) the \"src\" directory here, otherwise just " | 424 "path to (and including) the \"src\" directory here, otherwise just " |
| 433 "press <Return>: "), | 425 "press <Return>: "), |
| 434 self["chrome_path"] = self.ReadLine() | 426 self["chrome_path"] = self.ReadLine() |
| 435 | 427 |
| 436 | 428 |
| 437 class SwitchChromium(Step): | 429 class SwitchChromium(Step): |
| 438 MESSAGE = "Switch to Chromium checkout." | 430 MESSAGE = "Switch to Chromium checkout." |
| 439 REQUIRES = "chrome_path" | 431 REQUIRES = "chrome_path" |
| 440 | 432 |
| 441 def RunStep(self): | 433 def RunStep(self): |
| 442 self["v8_path"] = os.getcwd() | 434 self["v8_path"] = os.getcwd() |
| 443 os.chdir(self["chrome_path"]) | 435 os.chdir(self["chrome_path"]) |
| 444 self.InitialEnvironmentChecks() | 436 self.InitialEnvironmentChecks() |
| 445 # Check for a clean workdir. | 437 # Check for a clean workdir. |
| 446 if self.Git("status -s -uno").strip() != "": | 438 if not self.GitIsWorkdirClean(): |
| 447 self.Die("Workspace is not clean. Please commit or undo your changes.") | 439 self.Die("Workspace is not clean. Please commit or undo your changes.") |
| 448 # Assert that the DEPS file is there. | 440 # Assert that the DEPS file is there. |
| 449 if not os.path.exists(self.Config(DEPS_FILE)): | 441 if not os.path.exists(self.Config(DEPS_FILE)): |
| 450 self.Die("DEPS file not present.") | 442 self.Die("DEPS file not present.") |
| 451 | 443 |
| 452 | 444 |
| 453 class UpdateChromiumCheckout(Step): | 445 class UpdateChromiumCheckout(Step): |
| 454 MESSAGE = "Update the checkout and create a new branch." | 446 MESSAGE = "Update the checkout and create a new branch." |
| 455 REQUIRES = "chrome_path" | 447 REQUIRES = "chrome_path" |
| 456 | 448 |
| 457 def RunStep(self): | 449 def RunStep(self): |
| 458 os.chdir(self["chrome_path"]) | 450 os.chdir(self["chrome_path"]) |
| 459 self.Git("checkout master") | 451 self.GitCheckout("master") |
| 460 self.Git("pull") | 452 self.GitPull() |
| 461 self.Git("checkout -b v8-roll-%s" % self["trunk_revision"]) | 453 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"]) |
| 462 | 454 |
| 463 | 455 |
| 464 class UploadCL(Step): | 456 class UploadCL(Step): |
| 465 MESSAGE = "Create and upload CL." | 457 MESSAGE = "Create and upload CL." |
| 466 REQUIRES = "chrome_path" | 458 REQUIRES = "chrome_path" |
| 467 | 459 |
| 468 def RunStep(self): | 460 def RunStep(self): |
| 469 os.chdir(self["chrome_path"]) | 461 os.chdir(self["chrome_path"]) |
| 470 | 462 |
| 471 # Patch DEPS file. | 463 # Patch DEPS file. |
| 472 deps = FileToText(self.Config(DEPS_FILE)) | 464 deps = FileToText(self.Config(DEPS_FILE)) |
| 473 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", | 465 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", |
| 474 self["trunk_revision"], | 466 self["trunk_revision"], |
| 475 deps) | 467 deps) |
| 476 TextToFile(deps, self.Config(DEPS_FILE)) | 468 TextToFile(deps, self.Config(DEPS_FILE)) |
| 477 | 469 |
| 478 if self._options.reviewer: | 470 if self._options.reviewer: |
| 479 print "Using account %s for review." % self._options.reviewer | 471 print "Using account %s for review." % self._options.reviewer |
| 480 rev = self._options.reviewer | 472 rev = self._options.reviewer |
| 481 else: | 473 else: |
| 482 print "Please enter the email address of a reviewer for the roll CL: ", | 474 print "Please enter the email address of a reviewer for the roll CL: ", |
| 483 self.DieNoManualMode("A reviewer must be specified in forced mode.") | 475 self.DieNoManualMode("A reviewer must be specified in forced mode.") |
| 484 rev = self.ReadLine() | 476 rev = self.ReadLine() |
| 485 self.Git("commit -am \"Update V8 to version %s " | 477 suffix = PUSH_MESSAGE_SUFFIX % int(self["svn_revision"]) |
| 486 "(based on bleeding_edge revision r%s).\n\nTBR=%s\"" | 478 self.GitCommit("Update V8 to version %s%s.\n\nTBR=%s" |
| 487 % (self["version"], self["svn_revision"], rev)) | 479 % (self["version"], suffix, rev)) |
| 488 author_option = self._options.author | 480 self.GitUpload(author=self._options.author, |
| 489 author = " --email \"%s\"" % author_option if author_option else "" | 481 force=self._options.force_upload) |
| 490 force_flag = " -f" if self._options.force_upload else "" | |
| 491 self.Git("cl upload%s --send-mail%s" % (author, force_flag), pipe=False) | |
| 492 print "CL uploaded." | 482 print "CL uploaded." |
| 493 | 483 |
| 494 | 484 |
| 495 class SwitchV8(Step): | 485 class SwitchV8(Step): |
| 496 MESSAGE = "Returning to V8 checkout." | 486 MESSAGE = "Returning to V8 checkout." |
| 497 REQUIRES = "chrome_path" | 487 REQUIRES = "chrome_path" |
| 498 | 488 |
| 499 def RunStep(self): | 489 def RunStep(self): |
| 500 os.chdir(self["v8_path"]) | 490 os.chdir(self["v8_path"]) |
| 501 | 491 |
| 502 | 492 |
| 503 class CleanUp(Step): | 493 class CleanUp(Step): |
| 504 MESSAGE = "Done!" | 494 MESSAGE = "Done!" |
| 505 | 495 |
| 506 def RunStep(self): | 496 def RunStep(self): |
| 507 if self["chrome_path"]: | 497 if self["chrome_path"]: |
| 508 print("Congratulations, you have successfully created the trunk " | 498 print("Congratulations, you have successfully created the trunk " |
| 509 "revision %s and rolled it into Chromium. Please don't forget to " | 499 "revision %s and rolled it into Chromium. Please don't forget to " |
| 510 "update the v8rel spreadsheet:" % self["version"]) | 500 "update the v8rel spreadsheet:" % self["version"]) |
| 511 else: | 501 else: |
| 512 print("Congratulations, you have successfully created the trunk " | 502 print("Congratulations, you have successfully created the trunk " |
| 513 "revision %s. Please don't forget to roll this new version into " | 503 "revision %s. Please don't forget to roll this new version into " |
| 514 "Chromium, and to update the v8rel spreadsheet:" | 504 "Chromium, and to update the v8rel spreadsheet:" |
| 515 % self["version"]) | 505 % self["version"]) |
| 516 print "%s\ttrunk\t%s" % (self["version"], | 506 print "%s\ttrunk\t%s" % (self["version"], |
| 517 self["trunk_revision"]) | 507 self["trunk_revision"]) |
| 518 | 508 |
| 519 self.CommonCleanup() | 509 self.CommonCleanup() |
| 520 if self.Config(TRUNKBRANCH) != self["current_branch"]: | 510 if self.Config(TRUNKBRANCH) != self["current_branch"]: |
| 521 self.Git("branch -D %s" % self.Config(TRUNKBRANCH)) | 511 self.GitDeleteBranch(self.Config(TRUNKBRANCH)) |
| 522 | 512 |
| 523 | 513 |
| 524 def RunPushToTrunk(config, | 514 def RunPushToTrunk(config, |
| 525 options, | 515 options, |
| 526 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): | 516 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): |
| 527 step_classes = [ | 517 step_classes = [ |
| 528 Preparation, | 518 Preparation, |
| 529 FreshBranch, | 519 FreshBranch, |
| 530 DetectLastPush, | 520 DetectLastPush, |
| 531 PrepareChangeLog, | 521 PrepareChangeLog, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 def Main(): | 595 def Main(): |
| 606 parser = BuildOptions() | 596 parser = BuildOptions() |
| 607 (options, args) = parser.parse_args() | 597 (options, args) = parser.parse_args() |
| 608 if not ProcessOptions(options): | 598 if not ProcessOptions(options): |
| 609 parser.print_help() | 599 parser.print_help() |
| 610 return 1 | 600 return 1 |
| 611 RunPushToTrunk(CONFIG, PushToTrunkOptions(options)) | 601 RunPushToTrunk(CONFIG, PushToTrunkOptions(options)) |
| 612 | 602 |
| 613 if __name__ == "__main__": | 603 if __name__ == "__main__": |
| 614 sys.exit(Main()) | 604 sys.exit(Main()) |
| OLD | NEW |