Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: tools/findit/chromium_deps.py

Issue 504443004: [Findit] Improve output format and cherry-pick bugs fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/findit/chromium_deps_unittest.py » ('j') | tools/findit/chromium_deps_unittest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/findit/chromium_deps.py
diff --git a/tools/findit/chromium_deps.py b/tools/findit/chromium_deps.py
index e2b0b7c8c867c1eb23f42f6fb8866cb12d420c4a..ef117e7e3a56c04a2a4bd1c81743b602d9566817 100644
--- a/tools/findit/chromium_deps.py
+++ b/tools/findit/chromium_deps.py
@@ -66,15 +66,24 @@ def _GetComponentName(path, host_dirs):
return '_'.join(path.split('/'))
-def _GetContentOfDEPS(url, retries=5, sleep_time=0.1):
+def _GetContentOfDEPS(revision, retries=5, sleep_time=0.1):
+ chromium_git_file_url_template = CONFIG['chromium_git_file_url']
+ deps_file_name = '.DEPS.git'
+ url = chromium_git_file_url_template % (revision, deps_file_name)
count = 0
while True:
count += 1
try:
- _, content = utils.GetHttpClient().Get(url, timeout=60)
- return content
+ http_status_code, content = utils.GetHttpClient().Get(url, timeout=60)
aarya 2014/08/26 02:13:53 404 might cause an exception which will cause deps
stgao 2014/08/26 18:35:24 Good catch. Fix both here and the http_client. Th
+
+ if http_status_code == 404 and deps_file_name != 'DEPS':
+ deps_file_name = 'DEPS'
+ count = 0
+ continue
+ elif http_status_code == 200:
+ # Googlesource git returns text file encoded in base64, so decode it.
+ return base64.b64decode(content)
- # TODO(jeun): Handle HTTP Errors, such as 404.
except urllib2.HTTPError:
if count < retries:
time.sleep(sleep_time)
@@ -90,7 +99,7 @@ def GetChromiumComponents(chromium_revision,
"""Return a list of components used by Chrome of the given revision.
Args:
- chromium_revision: The revision of the Chrome build.
+ chromium_revision: Revision of the Chrome build: svn revision, or git hash.
os_platform: The target platform of the Chrome build, eg. win, mac, etc.
deps_file_downloader: A function that takes the chromium_revision as input,
and returns the content of the DEPS file. The returned
@@ -104,23 +113,20 @@ def GetChromiumComponents(chromium_revision,
if os_platform.lower() == 'linux':
os_platform = 'unix'
- git_base_url = CONFIG['git_base_url']
- git_deps_path = CONFIG['git_deps_path']
- svn_base_url = CONFIG['svn_base_url']
- svn_deps_path = CONFIG['svn_deps_path']
- svn_src_chromium_url = CONFIG['svn_src_chromium_url']
- is_git_hash = utils.IsGitHash(chromium_revision)
- if is_git_hash:
- url = git_base_url + (git_deps_path % chromium_revision)
- else:
- url = svn_base_url + (svn_deps_path % chromium_revision)
+ chromium_git_base_url = CONFIG['chromium_git_base_url']
- # Download the content of DEPS file in chromium.
- deps_content = deps_file_downloader(url)
+ if not utils.IsGitHash(chromium_revision):
+ # Convert svn revision or commit position to Git hash.
+ cr_rev_url_template = CONFIG['cr_rev_url']
+ url = cr_rev_url_template % chromium_revision
+ _, content = utils.GetHttpClient().Get(url, timeout=60)
+ cr_rev_data = json.loads(content)
+ if 'git_sha' not in cr_rev_data:
+ raise Exception('Failed to convert svn revision to git hash')
+ chromium_revision = cr_rev_data['git_sha']
- # Googlesource git returns text file encoded in base64, so decode it.
- if is_git_hash:
- deps_content = base64.b64decode(deps_content)
+ # Download the content of DEPS file in chromium.
+ deps_content = deps_file_downloader(chromium_revision)
all_deps = {}
@@ -133,16 +139,14 @@ def GetChromiumComponents(chromium_revision,
# Figure out components based on the dependencies.
components = {}
host_dirs = CONFIG['host_directories']
- for component_path in all_deps:
+ for component_path, component_repo_url in all_deps.iteritems():
+ if component_repo_url is None:
+ # For some platform like iso, some component is ignored.
+ continue
+
name = _GetComponentName(component_path, host_dirs)
- repository, revision = all_deps[component_path].split('@')
+ repository, revision = component_repo_url.split('@')
is_git_hash = utils.IsGitHash(revision)
- if repository.startswith('/'):
- # In DEPS file, if a path starts with /, it is a relative path to the
- # https://src.chromium.org/chrome. Strip /trunk at the end of the base
- # url and add it to the base url.
- # TODO(stgao): Use git repo after chromium moves to git.
- repository = svn_src_chromium_url + repository
if is_git_hash:
repository_type = 'git'
else:
@@ -157,19 +161,12 @@ def GetChromiumComponents(chromium_revision,
'revision': revision
}
- # Add chromium as a component, depending on the repository type.
- if is_git_hash:
- repository = git_base_url
- repository_type = 'git'
- else:
- repository = svn_base_url
- repository_type = 'svn'
-
+ # Add chromium as a component.
components['src/'] = {
'path': 'src/',
'name': 'chromium',
- 'repository': repository,
- 'repository_type': repository_type,
+ 'repository': chromium_git_base_url,
+ 'repository_type': 'git',
'revision': chromium_revision
}
« no previous file with comments | « no previous file | tools/findit/chromium_deps_unittest.py » ('j') | tools/findit/chromium_deps_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698