Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2014 the V8 project authors. All rights reserved. | |
| 3 # Redistribution and use in source and binary forms, with or without | |
|
Jakob Kummerow
2014/03/20 15:16:54
use the new short license header for new files
| |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following | |
| 11 # disclaimer in the documentation and/or other materials provided | |
| 12 # with the distribution. | |
| 13 # * Neither the name of Google Inc. nor the names of its | |
| 14 # contributors may be used to endorse or promote products derived | |
| 15 # from this software without specific prior written permission. | |
| 16 # | |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 28 | |
| 29 import argparse | |
| 30 import os | |
| 31 import sys | |
| 32 | |
| 33 from common_includes import * | |
| 34 | |
| 35 DEPS_FILE = "DEPS_FILE" | |
| 36 CHROMIUM = "CHROMIUM" | |
| 37 | |
| 38 CONFIG = { | |
| 39 PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile", | |
| 40 DOT_GIT_LOCATION: ".git", | |
| 41 DEPS_FILE: "DEPS", | |
| 42 } | |
| 43 | |
| 44 | |
| 45 class Preparation(Step): | |
| 46 MESSAGE = "Preparation." | |
| 47 | |
| 48 def RunStep(self): | |
| 49 self.CommonPrepare() | |
| 50 | |
| 51 | |
| 52 class DetectLastPush(Step): | |
| 53 MESSAGE = "Detect commit ID of last push to trunk." | |
| 54 | |
| 55 def RunStep(self): | |
| 56 self["last_push"] = self._options.last_push or self.FindLastTrunkPush() | |
| 57 self["trunk_revision"] = self.GitSVNFindSVNRev(self["last_push"]) | |
| 58 self["push_title"] = self.GitLog(n=1, format="%s", | |
| 59 git_hash=self["last_push"]) | |
| 60 | |
| 61 | |
| 62 class CheckChromium(Step): | |
| 63 MESSAGE = "Ask for chromium checkout." | |
| 64 | |
| 65 def Run(self): | |
| 66 self["chrome_path"] = self._options.chromium | |
| 67 if not self["chrome_path"]: | |
| 68 self.DieNoManualMode("Please specify the path to a Chromium checkout in " | |
| 69 "forced mode.") | |
| 70 print ("Do you have a \"NewGit\" Chromium checkout and want " | |
| 71 "this script to automate creation of the roll CL? If yes, enter the " | |
|
Jakob Kummerow
2014/03/20 15:16:54
This prompt doesn't make sense any more. Suggestio
| |
| 72 "path to (and including) the \"src\" directory here, otherwise just " | |
| 73 "press <Return>: "), | |
| 74 self["chrome_path"] = self.ReadLine() | |
| 75 | |
| 76 | |
| 77 class SwitchChromium(Step): | |
| 78 MESSAGE = "Switch to Chromium checkout." | |
| 79 REQUIRES = "chrome_path" | |
| 80 | |
| 81 def RunStep(self): | |
| 82 self["v8_path"] = os.getcwd() | |
| 83 os.chdir(self["chrome_path"]) | |
| 84 self.InitialEnvironmentChecks() | |
| 85 # Check for a clean workdir. | |
| 86 if not self.GitIsWorkdirClean(): # pragma: no cover | |
| 87 self.Die("Workspace is not clean. Please commit or undo your changes.") | |
| 88 # Assert that the DEPS file is there. | |
| 89 if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover | |
| 90 self.Die("DEPS file not present.") | |
| 91 | |
| 92 | |
| 93 class UpdateChromiumCheckout(Step): | |
| 94 MESSAGE = "Update the checkout and create a new branch." | |
| 95 REQUIRES = "chrome_path" | |
| 96 | |
| 97 def RunStep(self): | |
| 98 os.chdir(self["chrome_path"]) | |
| 99 self.GitCheckout("master") | |
| 100 self.GitPull() | |
| 101 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"]) | |
| 102 | |
| 103 | |
| 104 class UploadCL(Step): | |
| 105 MESSAGE = "Create and upload CL." | |
| 106 REQUIRES = "chrome_path" | |
| 107 | |
| 108 def RunStep(self): | |
| 109 os.chdir(self["chrome_path"]) | |
| 110 | |
| 111 # Patch DEPS file. | |
| 112 deps = FileToText(self.Config(DEPS_FILE)) | |
| 113 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", | |
| 114 self["trunk_revision"], | |
| 115 deps) | |
| 116 TextToFile(deps, self.Config(DEPS_FILE)) | |
| 117 | |
| 118 if self._options.reviewer: | |
| 119 print "Using account %s for review." % self._options.reviewer | |
| 120 rev = self._options.reviewer | |
| 121 else: | |
| 122 print "Please enter the email address of a reviewer for the roll CL: ", | |
| 123 self.DieNoManualMode("A reviewer must be specified in forced mode.") | |
| 124 rev = self.ReadLine() | |
| 125 | |
| 126 commit_title = "Update V8 to %s." % self["push_title"].lower() | |
| 127 self.GitCommit("%s\n\nTBR=%s" % (commit_title, rev)) | |
| 128 self.GitUpload(author=self._options.author, | |
| 129 force=self._options.force_upload) | |
| 130 print "CL uploaded." | |
| 131 | |
| 132 | |
| 133 class SwitchV8(Step): | |
| 134 MESSAGE = "Returning to V8 checkout." | |
| 135 REQUIRES = "chrome_path" | |
| 136 | |
| 137 def RunStep(self): | |
| 138 os.chdir(self["v8_path"]) | |
| 139 | |
| 140 | |
| 141 class CleanUp(Step): | |
| 142 MESSAGE = "Done!" | |
| 143 | |
| 144 def RunStep(self): | |
| 145 print("Congratulations, you have successfully rolled the push r%s it into " | |
| 146 "Chromium. Please don't forget to update the v8rel spreadsheet." | |
| 147 % self["trunk_revision"]) | |
| 148 | |
| 149 # Clean up all temporary files. | |
| 150 Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME]) | |
| 151 | |
| 152 | |
| 153 class ChromiumRoll(ScriptsBase): | |
| 154 def _PrepareOptions(self, parser): | |
| 155 group = parser.add_mutually_exclusive_group() | |
| 156 group.add_argument("-f", "--force", | |
| 157 help="Don't prompt the user.", | |
| 158 default=False, action="store_true") | |
| 159 group.add_argument("-m", "--manual", | |
| 160 help="Prompt the user at every important step.", | |
| 161 default=False, action="store_true") | |
| 162 parser.add_argument("-c", "--chromium", | |
| 163 help=("The path to your Chromium src/ " | |
| 164 "directory to automate the V8 roll.")) | |
| 165 parser.add_argument("-l", "--last-push", | |
| 166 help="The git commit ID of the last push to trunk.") | |
| 167 | |
| 168 def _ProcessOptions(self, options): # pragma: no cover | |
| 169 if not options.manual and not options.reviewer: | |
| 170 print "A reviewer (-r) is required in (semi-)automatic mode." | |
| 171 return False | |
| 172 if not options.manual and not options.chromium: | |
| 173 print "A chromium checkout (-c) is required in (semi-)automatic mode." | |
| 174 return False | |
| 175 if not options.manual and not options.author: | |
| 176 print "Specify your chromium.org email with -a in (semi-)automatic mode." | |
| 177 return False | |
| 178 | |
| 179 options.tbr_commit = not options.manual | |
| 180 return True | |
| 181 | |
| 182 def _Steps(self): | |
| 183 return [ | |
| 184 Preparation, | |
| 185 DetectLastPush, | |
| 186 CheckChromium, | |
| 187 SwitchChromium, | |
| 188 UpdateChromiumCheckout, | |
| 189 UploadCL, | |
| 190 SwitchV8, | |
| 191 CleanUp, | |
| 192 ] | |
| 193 | |
| 194 | |
| 195 if __name__ == "__main__": # pragma: no cover | |
| 196 sys.exit(ChromiumRoll(CONFIG).Run()) | |
| OLD | NEW |