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 * |
11 | 11 |
12 DEPS_FILE = "DEPS_FILE" | |
13 CHROMIUM = "CHROMIUM" | 12 CHROMIUM = "CHROMIUM" |
14 | 13 |
15 CONFIG = { | 14 CONFIG = { |
16 PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile", | 15 PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile", |
17 DOT_GIT_LOCATION: ".git", | 16 DOT_GIT_LOCATION: ".git", |
18 DEPS_FILE: "DEPS", | |
19 } | 17 } |
20 | 18 |
21 | 19 |
22 class Preparation(Step): | 20 class Preparation(Step): |
23 MESSAGE = "Preparation." | 21 MESSAGE = "Preparation." |
24 | 22 |
25 def RunStep(self): | 23 def RunStep(self): |
26 # Update v8 remote tracking branches. | 24 # Update v8 remote tracking branches. |
27 self.GitFetchOrigin() | 25 self.GitFetchOrigin() |
28 | 26 |
29 | 27 |
30 class DetectLastPush(Step): | 28 class DetectLastPush(Step): |
31 MESSAGE = "Detect commit ID of last push to trunk." | 29 MESSAGE = "Detect commit ID of last push to trunk." |
32 | 30 |
33 def RunStep(self): | 31 def RunStep(self): |
34 self["last_push"] = self._options.last_push or self.FindLastTrunkPush( | 32 self["last_push"] = self._options.last_push or self.FindLastTrunkPush( |
35 branch="origin/master", include_patches=True) | 33 branch="origin/master", include_patches=True) |
36 self["trunk_revision"] = self.GetCommitPositionNumber(self["last_push"]) | 34 self["trunk_revision"] = self.GetCommitPositionNumber(self["last_push"]) |
37 self["push_title"] = self.GitLog(n=1, format="%s", | 35 self["push_title"] = self.GitLog(n=1, format="%s", |
38 git_hash=self["last_push"]) | 36 git_hash=self["last_push"]) |
39 | 37 |
40 | 38 |
41 class SwitchChromium(Step): | 39 class SwitchChromium(Step): |
42 MESSAGE = "Switch to Chromium checkout." | 40 MESSAGE = "Switch to Chromium checkout." |
43 | 41 |
44 def RunStep(self): | 42 def RunStep(self): |
45 self["v8_path"] = os.getcwd() | 43 self["v8_path"] = os.getcwd() |
46 os.chdir(self._options.chromium) | 44 cwd = self._options.chromium |
| 45 os.chdir(cwd) |
47 self.InitialEnvironmentChecks() | 46 self.InitialEnvironmentChecks() |
48 # Check for a clean workdir. | 47 # Check for a clean workdir. |
49 if not self.GitIsWorkdirClean(): # pragma: no cover | 48 if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover |
50 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.") |
51 # Assert that the DEPS file is there. | 50 # Assert that the DEPS file is there. |
52 if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover | 51 if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover |
53 self.Die("DEPS file not present.") | 52 self.Die("DEPS file not present.") |
54 | 53 |
55 | 54 |
56 class UpdateChromiumCheckout(Step): | 55 class UpdateChromiumCheckout(Step): |
57 MESSAGE = "Update the checkout and create a new branch." | 56 MESSAGE = "Update the checkout and create a new branch." |
58 | 57 |
59 def RunStep(self): | 58 def RunStep(self): |
60 os.chdir(self._options.chromium) | 59 self.GitCheckout("master", cwd=self._options.chromium) |
61 self.GitCheckout("master") | 60 self.Command("gclient", "sync --nohooks", cwd=self._options.chromium) |
62 self._side_effect_handler.Command("gclient", "sync --nohooks") | 61 self.GitPull(cwd=self._options.chromium) |
63 self.GitPull() | 62 |
64 try: | 63 # Update v8 remotes. |
65 # TODO(machenbach): Add cwd to git calls. | 64 self.GitFetchOrigin() |
66 os.chdir(os.path.join(self._options.chromium, "v8")) | 65 |
67 self.GitFetchOrigin() | 66 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"], |
68 finally: | 67 cwd=self._options.chromium) |
69 os.chdir(self._options.chromium) | |
70 self.GitCreateBranch("v8-roll-%s" % self["trunk_revision"]) | |
71 | 68 |
72 | 69 |
73 class UploadCL(Step): | 70 class UploadCL(Step): |
74 MESSAGE = "Create and upload CL." | 71 MESSAGE = "Create and upload CL." |
75 | 72 |
76 def RunStep(self): | 73 def RunStep(self): |
77 os.chdir(self._options.chromium) | |
78 | |
79 # Patch DEPS file. | 74 # Patch DEPS file. |
80 if self._side_effect_handler.Command( | 75 if self.Command( |
81 "roll-dep", "v8 %s" % self["trunk_revision"]) is None: | 76 "roll-dep", "v8 %s" % self["trunk_revision"], |
| 77 cwd=self._options.chromium) is None: |
82 self.Die("Failed to create deps for %s" % self["trunk_revision"]) | 78 self.Die("Failed to create deps for %s" % self["trunk_revision"]) |
83 | 79 |
84 commit_title = "Update V8 to %s." % self["push_title"].lower() | 80 commit_title = "Update V8 to %s." % self["push_title"].lower() |
85 sheriff = "" | 81 sheriff = "" |
86 if self["sheriff"]: | 82 if self["sheriff"]: |
87 sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems." | 83 sheriff = ("\n\nPlease reply to the V8 sheriff %s in case of problems." |
88 % self["sheriff"]) | 84 % self["sheriff"]) |
89 self.GitCommit("%s%s\n\nTBR=%s" % | 85 self.GitCommit("%s%s\n\nTBR=%s" % |
90 (commit_title, sheriff, self._options.reviewer), | 86 (commit_title, sheriff, self._options.reviewer), |
91 author=self._options.author) | 87 author=self._options.author, |
| 88 cwd=self._options.chromium) |
92 if not self._options.dry_run: | 89 if not self._options.dry_run: |
93 self.GitUpload(author=self._options.author, | 90 self.GitUpload(author=self._options.author, |
94 force=True, | 91 force=True, |
95 cq=self._options.use_commit_queue) | 92 cq=self._options.use_commit_queue, |
| 93 cwd=self._options.chromium) |
96 print "CL uploaded." | 94 print "CL uploaded." |
97 else: | 95 else: |
98 self.GitCheckout("master") | 96 self.GitCheckout("master", cwd=self._options.chromium) |
99 self.GitDeleteBranch("v8-roll-%s" % self["trunk_revision"]) | 97 self.GitDeleteBranch("v8-roll-%s" % self["trunk_revision"], |
| 98 cwd=self._options.chromium) |
100 print "Dry run - don't upload." | 99 print "Dry run - don't upload." |
101 | 100 |
102 | 101 |
| 102 # TODO(machenbach): Make this obsolete. We are only in the chromium chechout |
| 103 # for the initial .git check. |
103 class SwitchV8(Step): | 104 class SwitchV8(Step): |
104 MESSAGE = "Returning to V8 checkout." | 105 MESSAGE = "Returning to V8 checkout." |
105 | 106 |
106 def RunStep(self): | 107 def RunStep(self): |
107 os.chdir(self["v8_path"]) | 108 os.chdir(self["v8_path"]) |
108 | 109 |
109 | 110 |
110 class CleanUp(Step): | 111 class CleanUp(Step): |
111 MESSAGE = "Done!" | 112 MESSAGE = "Done!" |
112 | 113 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 SwitchChromium, | 149 SwitchChromium, |
149 UpdateChromiumCheckout, | 150 UpdateChromiumCheckout, |
150 UploadCL, | 151 UploadCL, |
151 SwitchV8, | 152 SwitchV8, |
152 CleanUp, | 153 CleanUp, |
153 ] | 154 ] |
154 | 155 |
155 | 156 |
156 if __name__ == "__main__": # pragma: no cover | 157 if __name__ == "__main__": # pragma: no cover |
157 sys.exit(ChromiumRoll(CONFIG).Run()) | 158 sys.exit(ChromiumRoll(CONFIG).Run()) |
OLD | NEW |