Chromium Code Reviews| Index: appengine/findit/common/chromium_deps.py |
| diff --git a/appengine/findit/common/chromium_deps.py b/appengine/findit/common/chromium_deps.py |
| index 970b2df6dce69523948993dca745357711c35c59..5f0d96f57340178d469d887ef02bac4b3821ef31 100644 |
| --- a/appengine/findit/common/chromium_deps.py |
| +++ b/appengine/findit/common/chromium_deps.py |
| @@ -2,18 +2,33 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -from common import git_repository |
| -from common import http_client_appengine |
| +import re |
| + |
| from common import dependency |
| from common import deps_parser |
| - |
| +from common import git_repository |
| +from common import http_client_appengine |
| _CHROMIUM_ROOT_DIR = 'src/' |
|
stgao
2016/05/06 19:11:24
nit: one more line above.
Sharu Jiang
2016/05/06 20:27:27
Done.
|
| _CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git' |
| +_CHROME_VERSION_PATTERN = re.compile(r'^\d+\.\d+\.\d+\.\d+$') |
| + |
| +_BUILDSPEC_REPO = ('https://chrome-internal.googlesource.com/chrome/tools/' |
| + 'buildspec.git/') |
| + |
| + |
| +def IsChromeVersion(revision): |
| + """Determines if a revision is a chrome version.""" |
| + if _CHROME_VERSION_PATTERN.match(revision): |
| + return True |
| + |
| + return False |
| + |
| class DEPSDownloader(deps_parser.DEPSLoader): |
| """Downloads DEPS from remote Git repo.""" |
| + |
| def __init__(self, check_deps_git_first=False): |
| """ |
| Args: |
| @@ -50,16 +65,24 @@ def GetChromeDependency(revision, platform, check_deps_git_first=False): |
| """Returns all dependencies of Chrome as a dict for the given revision and OS. |
| Args: |
| - revision (str): The revision of a Chrome build. |
| + revision (str): The revision of a Chrome build, it can be a githash or a |
| + chrome version for a official build. |
| platform (str): The target platform of the Chrome build, should be one of |
| - 'win', 'ios', 'mac', 'unix', 'android', or 'all'. |
| + 'win', 'ios', 'mac', 'unix', 'android', or 'all'. |
| check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. |
| Returns: |
| A map from dependency path to the dependency info. |
| """ |
| + deps_repo_info = {'deps_file': 'DEPS'} |
| + |
| + if IsChromeVersion(revision): |
| + deps_repo_info['deps_repo_url'] = _BUILDSPEC_REPO |
|
stgao
2016/05/06 19:11:24
Mind a comment on why this updating is needed?
Sharu Jiang
2016/05/06 20:27:27
Done.
|
| + deps_repo_info['deps_repo_revision'] = 'master' |
| + deps_repo_info['deps_file'] = 'release/%s/DEPS' % revision |
| + |
| root_dep = dependency.Dependency( |
| - _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS') |
| + _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, **deps_repo_info) |
| deps_parser.UpdateDependencyTree( |
| root_dep, [platform], DEPSDownloader(check_deps_git_first)) |
| @@ -78,14 +101,21 @@ def GetChromeDependency(revision, platform, check_deps_git_first=False): |
| def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, |
| - check_deps_git_first=False): |
| + check_deps_git_first=False, skip_chromium_roll=True): |
| """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. |
| + old_cr_revision (str): The old Chromium revision, it can be a githash or a |
| + chrome version for a official build. |
| + new_cr_revision (str): The new Chromium revision, it can be a githash or a |
| + chrome version for a official build. |
| platform (str): The target OS platform of the Chrome or test binary. |
| check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. |
| + skip_chromium_roll (bool): If False, chromium roll will be contained in |
| + the return. |
| + |
| + Returns: |
| + A list of DependencyRoll objects in the revision range. |
| """ |
| old_deps = GetChromeDependency( |
| old_cr_revision, platform, check_deps_git_first) |
| @@ -95,7 +125,7 @@ def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, |
| rolls = [] |
| for path, new_dep in new_deps.iteritems(): |
| - if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium. |
| + if skip_chromium_roll and path == _CHROMIUM_ROOT_DIR: |
| continue |
| old_revision = None |
| @@ -117,22 +147,20 @@ def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, |
| def GetDEPSRollsDict(old_cr_revision, new_cr_revision, platform): |
| - """Gets dep_path to DependencyRoll dictionary for deps in |
| - (old_cr_revision, new_cr_revision]. |
| + """Gets dep_path to DependencyRoll dictionary for deps between 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. |
| + old_cr_revision (str): The old Chromium revision, it can be a githash or a |
| + chrome version for a official build. |
| + new_cr_revision (str): The new Chromium revision, it can be a githash or a |
| + chrome version for a official build. |
| platform (str): The target OS platform of the Chrome or test binary. |
| Returns: |
| - A dict, mapping dep path to DependencyRoll. |
| + A dict, mapping dep path to its DependencyRoll. |
| """ |
| - deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform) |
| - # Add chromium as dependency roll. |
| - deps_rolls.append(dependency.DependencyRoll( |
| - _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, |
| - old_cr_revision, new_cr_revision)) |
| + deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, |
| + skip_chromium_roll=False) |
| deps_rolls_dict = {} |
| for dep_roll in deps_rolls: |