Index: appengine/findit/common/chromium_deps.py |
diff --git a/appengine/findit/common/chromium_deps.py b/appengine/findit/common/chromium_deps.py |
index 079d67e2dd063fcd74b513c0b80d0510fb626c2d..eb9edcc4bd6cc9262181b8a708f402be1d3a1c8f 100644 |
--- a/appengine/findit/common/chromium_deps.py |
+++ b/appengine/findit/common/chromium_deps.py |
@@ -8,8 +8,12 @@ from common import dependency |
from common import deps_parser |
+_CHROMIUM_ROOT_DIR = 'src/' |
+_CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git' |
+ |
+ |
class DEPSDownloader(deps_parser.DEPSLoader): |
- """Download DEPS from remote GIT repo.""" |
+ """Downloads DEPS from remote Git repo.""" |
def Load(self, repo_url, revision, deps_file): |
http_client = http_client_appengine.HttpClientAppengine() |
@@ -18,13 +22,13 @@ class DEPSDownloader(deps_parser.DEPSLoader): |
content = None |
# Try .DEPS.git first if the given deps_file is "DEPS", because before |
- # migration from SVN to GIT, .DEPS.git contains dependencies from GIT while |
+ # migration from SVN to Git, .DEPS.git contains dependencies from Git while |
# DEPS contains those from SVN. |
if deps_file == 'DEPS': |
content = repo.GetSource('.DEPS.git', revision) |
# If .DEPS.git is not found, use DEPS. Assume it is a commit after migration |
- # from SVN to GIT. |
+ # from SVN to Git. |
if content is None: |
content = repo.GetSource(deps_file, revision) |
@@ -35,7 +39,7 @@ class DEPSDownloader(deps_parser.DEPSLoader): |
def GetChromeDependency(revision, os_platform): |
- """Return all dependencies of Chrome as a dict for the given revision and os. |
+ """Returns all dependencies of Chrome as a dict for the given revision and OS. |
Args: |
revision (str): The revision of a Chrome build. |
@@ -46,19 +50,50 @@ def GetChromeDependency(revision, os_platform): |
A map from dependency path to the dependency info. |
""" |
root_dep = dependency.Dependency( |
- 'src/', 'https://chromium.googlesource.com/chromium/src.git', revision, |
- 'DEPS') |
+ _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS') |
deps_parser.UpdateDependencyTree(root_dep, [os_platform], DEPSDownloader()) |
dependencies = {} |
# Flatten the dependency tree into a one-level dict. |
- def _FlattenDepTree(dep): |
+ def FlattenDepTree(dep): |
dependencies[dep.path] = dep |
for child in dep.children.values(): |
- _FlattenDepTree(child) |
+ FlattenDepTree(child) |
- _FlattenDepTree(root_dep) |
+ FlattenDepTree(root_dep) |
return dependencies |
+ |
+ |
+def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, os_platform): |
+ """Returns a list of dependency rolls between the given Chromium revisions. |
+ |
+ Args: |
+ old_cr_revision (str): The Git commit hash for the old Chromium revision. |
+ new_cr_revision (str): The Git commit hash for the new Chromium revision. |
+ os_platform (str): The target OS platform of the Chrome or test binary. |
+ """ |
+ old_deps = GetChromeDependency(old_cr_revision, os_platform) |
+ new_deps = GetChromeDependency(new_cr_revision, os_platform) |
+ |
+ rolls = [] |
+ |
+ for path, new_dep in new_deps.iteritems(): |
+ if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium. |
+ continue |
+ |
+ old_revision = None |
+ if path in old_deps: |
+ old_revision = old_deps[path].revision |
+ |
+ if old_revision != new_dep.revision: |
+ rolls.append( |
+ dependency.DependencyRoll( |
+ path, new_dep.repo_url, old_revision, new_dep.revision)) |
+ |
+ # Note: dependencies could be deleted too. However, regressions caused by that |
+ # seems rare. Thus, ignore them for now. |
+ |
+ return rolls |