OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from common import git_repository | 5 from common import git_repository |
6 from common import http_client_appengine | 6 from common import http_client_appengine |
7 from common import dependency | 7 from common import dependency |
8 from common import deps_parser | 8 from common import deps_parser |
9 | 9 |
10 | 10 |
| 11 _CHROMIUM_ROOT_DIR = 'src/' |
| 12 _CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git' |
| 13 |
| 14 |
11 class DEPSDownloader(deps_parser.DEPSLoader): | 15 class DEPSDownloader(deps_parser.DEPSLoader): |
12 """Download DEPS from remote GIT repo.""" | 16 """Downloads DEPS from remote Git repo.""" |
13 | 17 |
14 def Load(self, repo_url, revision, deps_file): | 18 def Load(self, repo_url, revision, deps_file): |
15 http_client = http_client_appengine.HttpClientAppengine() | 19 http_client = http_client_appengine.HttpClientAppengine() |
16 repo = git_repository.GitRepository(repo_url, http_client) | 20 repo = git_repository.GitRepository(repo_url, http_client) |
17 | 21 |
18 content = None | 22 content = None |
19 | 23 |
20 # Try .DEPS.git first if the given deps_file is "DEPS", because before | 24 # Try .DEPS.git first if the given deps_file is "DEPS", because before |
21 # migration from SVN to GIT, .DEPS.git contains dependencies from GIT while | 25 # migration from SVN to Git, .DEPS.git contains dependencies from Git while |
22 # DEPS contains those from SVN. | 26 # DEPS contains those from SVN. |
23 if deps_file == 'DEPS': | 27 if deps_file == 'DEPS': |
24 content = repo.GetSource('.DEPS.git', revision) | 28 content = repo.GetSource('.DEPS.git', revision) |
25 | 29 |
26 # If .DEPS.git is not found, use DEPS. Assume it is a commit after migration | 30 # If .DEPS.git is not found, use DEPS. Assume it is a commit after migration |
27 # from SVN to GIT. | 31 # from SVN to Git. |
28 if content is None: | 32 if content is None: |
29 content = repo.GetSource(deps_file, revision) | 33 content = repo.GetSource(deps_file, revision) |
30 | 34 |
31 if content is None: | 35 if content is None: |
32 raise Exception('Failed to pull %s file.' % deps_file) | 36 raise Exception('Failed to pull %s file.' % deps_file) |
33 | 37 |
34 return content | 38 return content |
35 | 39 |
36 | 40 |
37 def GetChromeDependency(revision, os_platform): | 41 def GetChromeDependency(revision, os_platform): |
38 """Return all dependencies of Chrome as a dict for the given revision and os. | 42 """Returns all dependencies of Chrome as a dict for the given revision and OS. |
39 | 43 |
40 Args: | 44 Args: |
41 revision (str): The revision of a Chrome build. | 45 revision (str): The revision of a Chrome build. |
42 os_platform (str): The target platform of the Chrome build, should be one of | 46 os_platform (str): The target platform of the Chrome build, should be one of |
43 'win', 'ios', 'mac', 'unix', 'android', or 'all'. | 47 'win', 'ios', 'mac', 'unix', 'android', or 'all'. |
44 | 48 |
45 Returns: | 49 Returns: |
46 A map from dependency path to the dependency info. | 50 A map from dependency path to the dependency info. |
47 """ | 51 """ |
48 root_dep = dependency.Dependency( | 52 root_dep = dependency.Dependency( |
49 'src/', 'https://chromium.googlesource.com/chromium/src.git', revision, | 53 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS') |
50 'DEPS') | |
51 | 54 |
52 deps_parser.UpdateDependencyTree(root_dep, [os_platform], DEPSDownloader()) | 55 deps_parser.UpdateDependencyTree(root_dep, [os_platform], DEPSDownloader()) |
53 | 56 |
54 dependencies = {} | 57 dependencies = {} |
55 | 58 |
56 # Flatten the dependency tree into a one-level dict. | 59 # Flatten the dependency tree into a one-level dict. |
57 def _FlattenDepTree(dep): | 60 def FlattenDepTree(dep): |
58 dependencies[dep.path] = dep | 61 dependencies[dep.path] = dep |
59 for child in dep.children.values(): | 62 for child in dep.children.values(): |
60 _FlattenDepTree(child) | 63 FlattenDepTree(child) |
61 | 64 |
62 _FlattenDepTree(root_dep) | 65 FlattenDepTree(root_dep) |
63 | 66 |
64 return dependencies | 67 return dependencies |
| 68 |
| 69 |
| 70 def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, os_platform): |
| 71 """Returns a list of dependency rolls between the given Chromium revisions. |
| 72 |
| 73 Args: |
| 74 old_cr_revision (str): The Git commit hash for the old Chromium revision. |
| 75 new_cr_revision (str): The Git commit hash for the new Chromium revision. |
| 76 os_platform (str): The target OS platform of the Chrome or test binary. |
| 77 """ |
| 78 old_deps = GetChromeDependency(old_cr_revision, os_platform) |
| 79 new_deps = GetChromeDependency(new_cr_revision, os_platform) |
| 80 |
| 81 rolls = [] |
| 82 |
| 83 for path, new_dep in new_deps.iteritems(): |
| 84 if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium. |
| 85 continue |
| 86 |
| 87 old_revision = None |
| 88 if path in old_deps: |
| 89 old_revision = old_deps[path].revision |
| 90 |
| 91 if old_revision != new_dep.revision: |
| 92 rolls.append( |
| 93 dependency.DependencyRoll( |
| 94 path, new_dep.repo_url, old_revision, new_dep.revision)) |
| 95 |
| 96 # Note: dependencies could be deleted too. However, regressions caused by that |
| 97 # seems rare. Thus, ignore them for now. |
| 98 |
| 99 return rolls |
OLD | NEW |