| 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 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 content = repo.GetSource(deps_file, revision) | 39 content = repo.GetSource(deps_file, revision) |
| 40 | 40 |
| 41 if content is None: | 41 if content is None: |
| 42 raise Exception( | 42 raise Exception( |
| 43 'Failed to pull %s file from %s, at revision %s.' % ( | 43 'Failed to pull %s file from %s, at revision %s.' % ( |
| 44 deps_file, repo_url, revision)) | 44 deps_file, repo_url, revision)) |
| 45 | 45 |
| 46 return content | 46 return content |
| 47 | 47 |
| 48 | 48 |
| 49 def GetChromeDependency(revision, os_platform, check_deps_git_first=False): | 49 def GetChromeDependency(revision, platform, check_deps_git_first=False): |
| 50 """Returns all dependencies of Chrome as a dict for the given revision and OS. | 50 """Returns all dependencies of Chrome as a dict for the given revision and OS. |
| 51 | 51 |
| 52 Args: | 52 Args: |
| 53 revision (str): The revision of a Chrome build. | 53 revision (str): The revision of a Chrome build. |
| 54 os_platform (str): The target platform of the Chrome build, should be one of | 54 platform (str): The target platform of the Chrome build, should be one of |
| 55 'win', 'ios', 'mac', 'unix', 'android', or 'all'. | 55 'win', 'ios', 'mac', 'unix', 'android', or 'all'. |
| 56 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. | 56 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. |
| 57 | 57 |
| 58 Returns: | 58 Returns: |
| 59 A map from dependency path to the dependency info. | 59 A map from dependency path to the dependency info. |
| 60 """ | 60 """ |
| 61 root_dep = dependency.Dependency( | 61 root_dep = dependency.Dependency( |
| 62 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS') | 62 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS') |
| 63 | 63 |
| 64 deps_parser.UpdateDependencyTree( | 64 deps_parser.UpdateDependencyTree( |
| 65 root_dep, [os_platform], DEPSDownloader(check_deps_git_first)) | 65 root_dep, [platform], DEPSDownloader(check_deps_git_first)) |
| 66 | 66 |
| 67 dependencies = {} | 67 dependencies = {} |
| 68 | 68 |
| 69 # Flatten the dependency tree into a one-level dict. | 69 # Flatten the dependency tree into a one-level dict. |
| 70 def FlattenDepTree(dep): | 70 def FlattenDepTree(dep): |
| 71 dependencies[dep.path] = dep | 71 dependencies[dep.path] = dep |
| 72 for child in dep.children.values(): | 72 for child in dep.children.values(): |
| 73 FlattenDepTree(child) | 73 FlattenDepTree(child) |
| 74 | 74 |
| 75 FlattenDepTree(root_dep) | 75 FlattenDepTree(root_dep) |
| 76 | 76 |
| 77 return dependencies | 77 return dependencies |
| 78 | 78 |
| 79 | 79 |
| 80 def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, os_platform, | 80 def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, |
| 81 check_deps_git_first=False): | 81 check_deps_git_first=False): |
| 82 """Returns a list of dependency rolls between the given Chromium revisions. | 82 """Returns a list of dependency rolls between the given Chromium revisions. |
| 83 | 83 |
| 84 Args: | 84 Args: |
| 85 old_cr_revision (str): The Git commit hash for the old Chromium revision. | 85 old_cr_revision (str): The Git commit hash for the old Chromium revision. |
| 86 new_cr_revision (str): The Git commit hash for the new Chromium revision. | 86 new_cr_revision (str): The Git commit hash for the new Chromium revision. |
| 87 os_platform (str): The target OS platform of the Chrome or test binary. | 87 platform (str): The target OS platform of the Chrome or test binary. |
| 88 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. | 88 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. |
| 89 """ | 89 """ |
| 90 old_deps = GetChromeDependency( | 90 old_deps = GetChromeDependency( |
| 91 old_cr_revision, os_platform, check_deps_git_first) | 91 old_cr_revision, platform, check_deps_git_first) |
| 92 new_deps = GetChromeDependency( | 92 new_deps = GetChromeDependency( |
| 93 new_cr_revision, os_platform, check_deps_git_first) | 93 new_cr_revision, platform, check_deps_git_first) |
| 94 | 94 |
| 95 rolls = [] | 95 rolls = [] |
| 96 | 96 |
| 97 for path, new_dep in new_deps.iteritems(): | 97 for path, new_dep in new_deps.iteritems(): |
| 98 if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium. | 98 if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium. |
| 99 continue | 99 continue |
| 100 | 100 |
| 101 old_revision = None | 101 old_revision = None |
| 102 if path in old_deps: | 102 if path in old_deps: |
| 103 old_revision = old_deps[path].revision | 103 old_revision = old_deps[path].revision |
| 104 | 104 |
| 105 if old_revision != new_dep.revision: | 105 if old_revision != new_dep.revision: |
| 106 rolls.append( | 106 rolls.append( |
| 107 dependency.DependencyRoll( | 107 dependency.DependencyRoll( |
| 108 path, new_dep.repo_url, old_revision, new_dep.revision)) | 108 path, new_dep.repo_url, old_revision, new_dep.revision)) |
| 109 | 109 |
| 110 for path, old_dep in old_deps.iteritems(): | 110 for path, old_dep in old_deps.iteritems(): |
| 111 if path not in new_deps: | 111 if path not in new_deps: |
| 112 rolls.append( | 112 rolls.append( |
| 113 dependency.DependencyRoll( | 113 dependency.DependencyRoll( |
| 114 path, old_dep.repo_url, old_dep.revision, None)) | 114 path, old_dep.repo_url, old_dep.revision, None)) |
| 115 | 115 |
| 116 return rolls | 116 return rolls |
| 117 |
| 118 |
| 119 def GetDEPSRollsDict(old_cr_revision, new_cr_revision, platform): |
| 120 """Gets dep_path to DependencyRoll dictionary for deps in |
| 121 (old_cr_revision, new_cr_revision]. |
| 122 |
| 123 Args: |
| 124 old_cr_revision (str): The Git commit hash for the old Chromium revision. |
| 125 new_cr_revision (str): The Git commit hash for the new Chromium revision. |
| 126 platform (str): The target OS platform of the Chrome or test binary. |
| 127 |
| 128 Returns: |
| 129 A dict, mapping dep path to DependencyRoll. |
| 130 """ |
| 131 deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform) |
| 132 # Add chromium as dependency roll. |
| 133 deps_rolls.append(dependency.DependencyRoll( |
| 134 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, |
| 135 old_cr_revision, new_cr_revision)) |
| 136 |
| 137 deps_rolls_dict = {} |
| 138 for dep_roll in deps_rolls: |
| 139 deps_rolls_dict[dep_roll.path] = dep_roll |
| 140 |
| 141 return deps_rolls_dict |
| OLD | NEW |