OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import argparse |
| 7 import os |
| 8 import sys |
| 9 |
| 10 from common_includes import * |
| 11 |
| 12 DEPS_FILE = "DEPS_FILE" |
| 13 CHROMIUM = "CHROMIUM" |
| 14 |
| 15 CONFIG = { |
| 16 PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile", |
| 17 DOT_GIT_LOCATION: ".git", |
| 18 DEPS_FILE: "DEPS", |
| 19 } |
| 20 |
| 21 |
| 22 class Preparation(Step): |
| 23 MESSAGE = "Preparation." |
| 24 |
| 25 def RunStep(self): |
| 26 self.CommonPrepare() |
| 27 |
| 28 |
| 29 class DetectLastPush(Step): |
| 30 MESSAGE = "Detect commit ID of last push to trunk." |
| 31 |
| 32 def RunStep(self): |
| 33 self["last_push"] = self._options.last_push or self.FindLastTrunkPush() |
| 34 self["trunk_revision"] = self.GitSVNFindSVNRev(self["last_push"]) |
| 35 self["push_title"] = self.GitLog(n=1, format="%s", |
| 36 git_hash=self["last_push"]) |
| 37 |
| 38 |
| 39 class CheckChromium(Step): |
| 40 MESSAGE = "Ask for chromium checkout." |
| 41 |
| 42 def Run(self): |
| 43 self["chrome_path"] = self._options.chromium |
| 44 while not self["chrome_path"]: |
| 45 self.DieNoManualMode("Please specify the path to a Chromium checkout in " |
| 46 "forced mode.") |
| 47 print ("Please specify the path to the chromium \"src\" directory: "), |
| 48 self["chrome_path"] = self.ReadLine() |
| 49 |
| 50 |
| 51 class SwitchChromium(Step): |
| 52 MESSAGE = "Switch to Chromium checkout." |
| 53 REQUIRES = "chrome_path" |
| 54 |
| 55 def RunStep(self): |
| 56 self["v8_path"] = os.getcwd() |
| 57 os.chdir(self["chrome_path"]) |
| 58 self.InitialEnvironmentChecks() |
| 59 # Check for a clean workdir. |
| 60 if not self.GitIsWorkdirClean(): # pragma: no cover |
| 61 self.Die("Workspace is not clean. Please commit or undo your changes.") |
| 62 # Assert that the DEPS file is there. |
| 63 if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover |
| 64 self.Die("DEPS file not present.") |
| 65 |
| 66 |
| 67 class UpdateChromiumCheckout(Step): |
| 68 MESSAGE = "Update the checkout and create a new branch." |
| 69 REQUIRES = "chrome_path" |
| 70 |
| 71 def RunStep(self): |
| 72 os.chdir(self["chrome_path"]) |
| 73 self.GitCheckout("master") |
| 74 self.GitPull() |
| 75 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"]) |
| 76 |
| 77 |
| 78 class UploadCL(Step): |
| 79 MESSAGE = "Create and upload CL." |
| 80 REQUIRES = "chrome_path" |
| 81 |
| 82 def RunStep(self): |
| 83 os.chdir(self["chrome_path"]) |
| 84 |
| 85 # Patch DEPS file. |
| 86 deps = FileToText(self.Config(DEPS_FILE)) |
| 87 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", |
| 88 self["trunk_revision"], |
| 89 deps) |
| 90 TextToFile(deps, self.Config(DEPS_FILE)) |
| 91 |
| 92 if self._options.reviewer: |
| 93 print "Using account %s for review." % self._options.reviewer |
| 94 rev = self._options.reviewer |
| 95 else: |
| 96 print "Please enter the email address of a reviewer for the roll CL: ", |
| 97 self.DieNoManualMode("A reviewer must be specified in forced mode.") |
| 98 rev = self.ReadLine() |
| 99 |
| 100 commit_title = "Update V8 to %s." % self["push_title"].lower() |
| 101 self.GitCommit("%s\n\nTBR=%s" % (commit_title, rev)) |
| 102 self.GitUpload(author=self._options.author, |
| 103 force=self._options.force_upload) |
| 104 print "CL uploaded." |
| 105 |
| 106 |
| 107 class SwitchV8(Step): |
| 108 MESSAGE = "Returning to V8 checkout." |
| 109 REQUIRES = "chrome_path" |
| 110 |
| 111 def RunStep(self): |
| 112 os.chdir(self["v8_path"]) |
| 113 |
| 114 |
| 115 class CleanUp(Step): |
| 116 MESSAGE = "Done!" |
| 117 |
| 118 def RunStep(self): |
| 119 print("Congratulations, you have successfully rolled the push r%s it into " |
| 120 "Chromium. Please don't forget to update the v8rel spreadsheet." |
| 121 % self["trunk_revision"]) |
| 122 |
| 123 # Clean up all temporary files. |
| 124 Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME]) |
| 125 |
| 126 |
| 127 class ChromiumRoll(ScriptsBase): |
| 128 def _PrepareOptions(self, parser): |
| 129 group = parser.add_mutually_exclusive_group() |
| 130 group.add_argument("-f", "--force", |
| 131 help="Don't prompt the user.", |
| 132 default=False, action="store_true") |
| 133 group.add_argument("-m", "--manual", |
| 134 help="Prompt the user at every important step.", |
| 135 default=False, action="store_true") |
| 136 parser.add_argument("-c", "--chromium", |
| 137 help=("The path to your Chromium src/ " |
| 138 "directory to automate the V8 roll.")) |
| 139 parser.add_argument("-l", "--last-push", |
| 140 help="The git commit ID of the last push to trunk.") |
| 141 |
| 142 def _ProcessOptions(self, options): # pragma: no cover |
| 143 if not options.manual and not options.reviewer: |
| 144 print "A reviewer (-r) is required in (semi-)automatic mode." |
| 145 return False |
| 146 if not options.manual and not options.chromium: |
| 147 print "A chromium checkout (-c) is required in (semi-)automatic mode." |
| 148 return False |
| 149 if not options.manual and not options.author: |
| 150 print "Specify your chromium.org email with -a in (semi-)automatic mode." |
| 151 return False |
| 152 |
| 153 options.tbr_commit = not options.manual |
| 154 return True |
| 155 |
| 156 def _Steps(self): |
| 157 return [ |
| 158 Preparation, |
| 159 DetectLastPush, |
| 160 CheckChromium, |
| 161 SwitchChromium, |
| 162 UpdateChromiumCheckout, |
| 163 UploadCL, |
| 164 SwitchV8, |
| 165 CleanUp, |
| 166 ] |
| 167 |
| 168 |
| 169 if __name__ == "__main__": # pragma: no cover |
| 170 sys.exit(ChromiumRoll(CONFIG).Run()) |
OLD | NEW |