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