| 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: | 9 # Requires a chromium checkout with branch heads: |
| 10 # gclient sync --with_branch_heads | 10 # gclient sync --with_branch_heads |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 DEPS_RE = re.compile(r"""^\s*(?:["']v8_revision["']: ["']""" | 50 DEPS_RE = re.compile(r"""^\s*(?:["']v8_revision["']: ["']""" |
| 51 """|\(Var\("googlecode_url"\) % "v8"\) \+ "\/trunk@""" | 51 """|\(Var\("googlecode_url"\) % "v8"\) \+ "\/trunk@""" |
| 52 """|"http\:\/\/v8\.googlecode\.com\/svn\/trunk@)""" | 52 """|"http\:\/\/v8\.googlecode\.com\/svn\/trunk@)""" |
| 53 """([^"']+)["'].*$""", re.M) | 53 """([^"']+)["'].*$""", re.M) |
| 54 | 54 |
| 55 # Expression to pick tag and revision for bleeding edge tags. To be used with | 55 # Expression to pick tag and revision for bleeding edge tags. To be used with |
| 56 # output of 'svn log'. | 56 # output of 'svn log'. |
| 57 BLEEDING_EDGE_TAGS_RE = re.compile( | 57 BLEEDING_EDGE_TAGS_RE = re.compile( |
| 58 r"A \/tags\/([^\s]+) \(from \/branches\/bleeding_edge\:(\d+)\)") | 58 r"A \/tags\/([^\s]+) \(from \/branches\/bleeding_edge\:(\d+)\)") |
| 59 | 59 |
| 60 # Regular expression that matches a single commit footer line. | |
| 61 COMMIT_FOOTER_ENTRY_RE = re.compile(r'([^:]+):\s+(.+)') | |
| 62 | |
| 63 # Footer metadata key for commit position. | |
| 64 COMMIT_POSITION_FOOTER_KEY = 'Cr-Commit-Position' | |
| 65 | |
| 66 # Regular expression to parse a commit position | |
| 67 COMMIT_POSITION_RE = re.compile(r'(.+)@\{#(\d+)\}') | |
| 68 | |
| 69 # Key for the 'git-svn' ID metadata commit footer entry. | |
| 70 GIT_SVN_ID_FOOTER_KEY = 'git-svn-id' | |
| 71 | |
| 72 # e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117 | |
| 73 # ce2b1a6d-e550-0410-aec6-3dcde31c8c00 | |
| 74 GIT_SVN_ID_RE = re.compile(r'((?:\w+)://[^@]+)@(\d+)\s+(?:[a-zA-Z0-9\-]+)') | |
| 75 | |
| 76 | |
| 77 # Copied from bot_update.py. | |
| 78 def GetCommitMessageFooterMap(message): | |
| 79 """Returns: (dict) A dictionary of commit message footer entries. | |
| 80 """ | |
| 81 footers = {} | |
| 82 | |
| 83 # Extract the lines in the footer block. | |
| 84 lines = [] | |
| 85 for line in message.strip().splitlines(): | |
| 86 line = line.strip() | |
| 87 if len(line) == 0: | |
| 88 del(lines[:]) | |
| 89 continue | |
| 90 lines.append(line) | |
| 91 | |
| 92 # Parse the footer | |
| 93 for line in lines: | |
| 94 m = COMMIT_FOOTER_ENTRY_RE.match(line) | |
| 95 if not m: | |
| 96 # If any single line isn't valid, the entire footer is invalid. | |
| 97 footers.clear() | |
| 98 return footers | |
| 99 footers[m.group(1)] = m.group(2).strip() | |
| 100 return footers | |
| 101 | |
| 102 | |
| 103 # Copied from bot_update.py and modified for svn-like numbers only. | |
| 104 def GetCommitPositionNumber(step, git_hash): | |
| 105 """Dumps the 'git' log for a specific revision and parses out the commit | |
| 106 position number. | |
| 107 | |
| 108 If a commit position metadata key is found, its number will be returned. | |
| 109 | |
| 110 Otherwise, we will search for a 'git-svn' metadata entry. If one is found, | |
| 111 its SVN revision value is returned. | |
| 112 """ | |
| 113 git_log = step.GitLog(format='%B', n=1, git_hash=git_hash) | |
| 114 footer_map = GetCommitMessageFooterMap(git_log) | |
| 115 | |
| 116 # Search for commit position metadata | |
| 117 value = footer_map.get(COMMIT_POSITION_FOOTER_KEY) | |
| 118 if value: | |
| 119 match = COMMIT_POSITION_RE.match(value) | |
| 120 if match: | |
| 121 return match.group(2) | |
| 122 | |
| 123 # Extract the svn revision from 'git-svn' metadata | |
| 124 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) | |
| 125 if value: | |
| 126 match = GIT_SVN_ID_RE.match(value) | |
| 127 if match: | |
| 128 return match.group(2) | |
| 129 return None | |
| 130 | |
| 131 | 60 |
| 132 def SortBranches(branches): | 61 def SortBranches(branches): |
| 133 """Sort branches with version number names.""" | 62 """Sort branches with version number names.""" |
| 134 return sorted(branches, key=SortingKey, reverse=True) | 63 return sorted(branches, key=SortingKey, reverse=True) |
| 135 | 64 |
| 136 | 65 |
| 137 def FilterDuplicatesAndReverse(cr_releases): | 66 def FilterDuplicatesAndReverse(cr_releases): |
| 138 """Returns the chromium releases in reverse order filtered by v8 revision | 67 """Returns the chromium releases in reverse order filtered by v8 revision |
| 139 duplicates. | 68 duplicates. |
| 140 | 69 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 cr_releases = [] | 341 cr_releases = [] |
| 413 try: | 342 try: |
| 414 for git_hash in self.GitLog(format="%H", grep="V8").splitlines(): | 343 for git_hash in self.GitLog(format="%H", grep="V8").splitlines(): |
| 415 if self._config[DEPS_FILE] not in self.GitChangedFiles(git_hash): | 344 if self._config[DEPS_FILE] not in self.GitChangedFiles(git_hash): |
| 416 continue | 345 continue |
| 417 if not self.GitCheckoutFileSafe(self._config[DEPS_FILE], git_hash): | 346 if not self.GitCheckoutFileSafe(self._config[DEPS_FILE], git_hash): |
| 418 break # pragma: no cover | 347 break # pragma: no cover |
| 419 deps = FileToText(self.Config(DEPS_FILE)) | 348 deps = FileToText(self.Config(DEPS_FILE)) |
| 420 match = DEPS_RE.search(deps) | 349 match = DEPS_RE.search(deps) |
| 421 if match: | 350 if match: |
| 422 cr_rev = GetCommitPositionNumber(self, git_hash) | 351 cr_rev = self.GetCommitPositionNumber(git_hash) |
| 423 if cr_rev: | 352 if cr_rev: |
| 424 v8_rev = ConvertToCommitNumber(self, match.group(1)) | 353 v8_rev = ConvertToCommitNumber(self, match.group(1)) |
| 425 cr_releases.append([cr_rev, v8_rev]) | 354 cr_releases.append([cr_rev, v8_rev]) |
| 426 | 355 |
| 427 # Stop after reaching beyond the last v8 revision we want to update. | 356 # Stop after reaching beyond the last v8 revision we want to update. |
| 428 # We need a small buffer for possible revert/reland frenzies. | 357 # We need a small buffer for possible revert/reland frenzies. |
| 429 # TODO(machenbach): Subtraction is not git friendly. | 358 # TODO(machenbach): Subtraction is not git friendly. |
| 430 if int(v8_rev) < oldest_v8_rev - 100: | 359 if int(v8_rev) < oldest_v8_rev - 100: |
| 431 break # pragma: no cover | 360 break # pragma: no cover |
| 432 | 361 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 RetrieveChromiumV8Releases, | 494 RetrieveChromiumV8Releases, |
| 566 RietrieveChromiumBranches, | 495 RietrieveChromiumBranches, |
| 567 SwitchV8, | 496 SwitchV8, |
| 568 CleanUp, | 497 CleanUp, |
| 569 WriteOutput, | 498 WriteOutput, |
| 570 ] | 499 ] |
| 571 | 500 |
| 572 | 501 |
| 573 if __name__ == "__main__": # pragma: no cover | 502 if __name__ == "__main__": # pragma: no cover |
| 574 sys.exit(Releases(CONFIG).Run()) | 503 sys.exit(Releases(CONFIG).Run()) |
| OLD | NEW |