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 # This script retrieves the history of all V8 branches and trunk revisions and | 6 # This script retrieves the history of all V8 branches and trunk revisions and |
7 # their corresponding Chromium revisions. | 7 # their corresponding Chromium revisions. |
8 | 8 |
| 9 # Requires a chromium checkout with branch heads: |
| 10 # gclient sync --with_branch_heads |
| 11 # gclient fetch |
| 12 |
9 import argparse | 13 import argparse |
10 import csv | 14 import csv |
11 import itertools | 15 import itertools |
12 import json | 16 import json |
13 import os | 17 import os |
14 import re | 18 import re |
15 import sys | 19 import sys |
16 | 20 |
17 from common_includes import * | 21 from common_includes import * |
18 | 22 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 result.append(release) | 84 result.append(release) |
81 return result | 85 return result |
82 | 86 |
83 | 87 |
84 def BuildRevisionRanges(cr_releases): | 88 def BuildRevisionRanges(cr_releases): |
85 """Returns a mapping of v8 revision -> chromium ranges. | 89 """Returns a mapping of v8 revision -> chromium ranges. |
86 The ranges are comma-separated, each range has the form R1:R2. The newest | 90 The ranges are comma-separated, each range has the form R1:R2. The newest |
87 entry is the only one of the form R1, as there is no end range. | 91 entry is the only one of the form R1, as there is no end range. |
88 | 92 |
89 cr_releases is a list of [cr_rev, v8_rev] reverse-sorted by cr_rev. | 93 cr_releases is a list of [cr_rev, v8_rev] reverse-sorted by cr_rev. |
| 94 cr_rev either refers to a chromium svn revision or a chromium branch number. |
90 """ | 95 """ |
91 range_lists = {} | 96 range_lists = {} |
92 cr_releases = FilterDuplicatesAndReverse(cr_releases) | 97 cr_releases = FilterDuplicatesAndReverse(cr_releases) |
93 | 98 |
94 # Visit pairs of cr releases from oldest to newest. | 99 # Visit pairs of cr releases from oldest to newest. |
95 for cr_from, cr_to in itertools.izip( | 100 for cr_from, cr_to in itertools.izip( |
96 cr_releases, itertools.islice(cr_releases, 1, None)): | 101 cr_releases, itertools.islice(cr_releases, 1, None)): |
97 | 102 |
98 # Assume the chromium revisions are all different. | 103 # Assume the chromium revisions are all different. |
99 assert cr_from[0] != cr_to[0] | 104 assert cr_from[0] != cr_to[0] |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 # The branch name. | 172 # The branch name. |
168 "branch": branch, | 173 "branch": branch, |
169 # The version for displaying in the form 3.26.3 or 3.26.3.12. | 174 # The version for displaying in the form 3.26.3 or 3.26.3.12. |
170 "version": version, | 175 "version": version, |
171 # The date of the commit. | 176 # The date of the commit. |
172 "date": self.GitLog(n=1, format="%ci", git_hash=git_hash), | 177 "date": self.GitLog(n=1, format="%ci", git_hash=git_hash), |
173 # Merged patches if available in the form 'r1234, r2345'. | 178 # Merged patches if available in the form 'r1234, r2345'. |
174 "patches_merged": patches, | 179 "patches_merged": patches, |
175 # Default for easier output formatting. | 180 # Default for easier output formatting. |
176 "chromium_revision": "", | 181 "chromium_revision": "", |
| 182 # Default for easier output formatting. |
| 183 "chromium_branch": "", |
177 # Link to the CL on code review. Trunk pushes are not uploaded, so this | 184 # Link to the CL on code review. Trunk pushes are not uploaded, so this |
178 # field will be populated below with the recent roll CL link. | 185 # field will be populated below with the recent roll CL link. |
179 "review_link": MatchSafe(REVIEW_LINK_RE.search(body)), | 186 "review_link": MatchSafe(REVIEW_LINK_RE.search(body)), |
180 # Link to the commit message on google code. | 187 # Link to the commit message on google code. |
181 "revision_link": ("https://code.google.com/p/v8/source/detail?r=%s" | 188 "revision_link": ("https://code.google.com/p/v8/source/detail?r=%s" |
182 % revision), | 189 % revision), |
183 }, self["patch"] | 190 }, self["patch"] |
184 | 191 |
185 def GetReleasesFromBranch(self, branch): | 192 def GetReleasesFromBranch(self, branch): |
186 self.GitReset("svn/%s" % branch) | 193 self.GitReset("svn/%s" % branch) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 326 |
320 # Clean up. | 327 # Clean up. |
321 self.GitCheckoutFileSafe(self._config[DEPS_FILE], "HEAD") | 328 self.GitCheckoutFileSafe(self._config[DEPS_FILE], "HEAD") |
322 | 329 |
323 # Add the chromium ranges to the v8 trunk releases. | 330 # Add the chromium ranges to the v8 trunk releases. |
324 all_ranges = BuildRevisionRanges(cr_releases) | 331 all_ranges = BuildRevisionRanges(cr_releases) |
325 trunk_dict = dict((r["revision"], r) for r in trunk_releases) | 332 trunk_dict = dict((r["revision"], r) for r in trunk_releases) |
326 for revision, ranges in all_ranges.iteritems(): | 333 for revision, ranges in all_ranges.iteritems(): |
327 trunk_dict.get(revision, {})["chromium_revision"] = ranges | 334 trunk_dict.get(revision, {})["chromium_revision"] = ranges |
328 | 335 |
| 336 |
| 337 # TODO(machenbach): Unify common code with method above. |
| 338 class RietrieveChromiumBranches(Step): |
| 339 MESSAGE = "Retrieve Chromium branch information." |
| 340 REQUIRES = "chrome_path" |
| 341 |
| 342 def RunStep(self): |
| 343 os.chdir(self["chrome_path"]) |
| 344 |
| 345 trunk_releases = filter(lambda r: r["branch"] == "trunk", self["releases"]) |
| 346 if not trunk_releases: # pragma: no cover |
| 347 print "No trunk releases detected. Skipping chromium history." |
| 348 return True |
| 349 |
| 350 oldest_v8_rev = int(trunk_releases[-1]["revision"]) |
| 351 |
| 352 # Filter out irrelevant branches. |
| 353 branches = filter(lambda r: re.match(r"branch-heads/\d+", r), |
| 354 self.GitRemotes()) |
| 355 |
| 356 # Transform into pure branch numbers. |
| 357 branches = map(lambda r: int(re.match(r"branch-heads/(\d+)", r).group(1)), |
| 358 branches) |
| 359 |
| 360 branches = sorted(branches, reverse=True) |
| 361 |
| 362 cr_branches = [] |
| 363 try: |
| 364 for branch in branches: |
| 365 if not self.GitCheckoutFileSafe(self._config[DEPS_FILE], |
| 366 "branch-heads/%d" % branch): |
| 367 break # pragma: no cover |
| 368 deps = FileToText(self.Config(DEPS_FILE)) |
| 369 match = DEPS_RE.search(deps) |
| 370 if match: |
| 371 v8_rev = match.group(1) |
| 372 cr_branches.append([str(branch), v8_rev]) |
| 373 |
| 374 # Stop after reaching beyond the last v8 revision we want to update. |
| 375 # We need a small buffer for possible revert/reland frenzies. |
| 376 # TODO(machenbach): Subtraction is not git friendly. |
| 377 if int(v8_rev) < oldest_v8_rev - 100: |
| 378 break # pragma: no cover |
| 379 |
| 380 # Allow Ctrl-C interrupt. |
| 381 except (KeyboardInterrupt, SystemExit): # pragma: no cover |
| 382 pass |
| 383 |
| 384 # Clean up. |
| 385 self.GitCheckoutFileSafe(self._config[DEPS_FILE], "HEAD") |
| 386 |
| 387 # Add the chromium branches to the v8 trunk releases. |
| 388 all_ranges = BuildRevisionRanges(cr_branches) |
| 389 trunk_dict = dict((r["revision"], r) for r in trunk_releases) |
| 390 for revision, ranges in all_ranges.iteritems(): |
| 391 trunk_dict.get(revision, {})["chromium_branch"] = ranges |
| 392 |
| 393 |
329 class SwitchV8(Step): | 394 class SwitchV8(Step): |
330 MESSAGE = "Returning to V8 checkout." | 395 MESSAGE = "Returning to V8 checkout." |
331 REQUIRES = "chrome_path" | 396 REQUIRES = "chrome_path" |
332 | 397 |
333 def RunStep(self): | 398 def RunStep(self): |
334 self.GitCheckout("master") | 399 self.GitCheckout("master") |
335 self.GitDeleteBranch(self.Config(BRANCHNAME)) | 400 self.GitDeleteBranch(self.Config(BRANCHNAME)) |
336 os.chdir(self["v8_path"]) | 401 os.chdir(self["v8_path"]) |
337 | 402 |
338 | 403 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 return True | 446 return True |
382 | 447 |
383 def _Steps(self): | 448 def _Steps(self): |
384 return [ | 449 return [ |
385 Preparation, | 450 Preparation, |
386 RetrieveV8Releases, | 451 RetrieveV8Releases, |
387 CheckChromium, | 452 CheckChromium, |
388 SwitchChromium, | 453 SwitchChromium, |
389 UpdateChromiumCheckout, | 454 UpdateChromiumCheckout, |
390 RetrieveChromiumV8Releases, | 455 RetrieveChromiumV8Releases, |
| 456 RietrieveChromiumBranches, |
391 SwitchV8, | 457 SwitchV8, |
392 CleanUp, | 458 CleanUp, |
393 WriteOutput, | 459 WriteOutput, |
394 ] | 460 ] |
395 | 461 |
396 | 462 |
397 if __name__ == "__main__": # pragma: no cover | 463 if __name__ == "__main__": # pragma: no cover |
398 sys.exit(Releases(CONFIG).Run()) | 464 sys.exit(Releases(CONFIG).Run()) |
OLD | NEW |