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

Side by Side Diff: appengine/findit/common/chromium_deps.py

Issue 1950123003: [Findit] Fetch DEPS from buildspec/ instead of trunk for chrome official builds. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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 import re
6
7 from common import dependency
8 from common import deps_parser
5 from common import git_repository 9 from common import git_repository
6 from common import http_client_appengine 10 from common import http_client_appengine
7 from common import dependency
8 from common import deps_parser
9
10 11
11 _CHROMIUM_ROOT_DIR = 'src/' 12 _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.
12 _CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git' 13 _CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git'
13 14
15 _CHROME_VERSION_PATTERN = re.compile(r'^\d+\.\d+\.\d+\.\d+$')
16
17 _BUILDSPEC_REPO = ('https://chrome-internal.googlesource.com/chrome/tools/'
18 'buildspec.git/')
19
20
21 def IsChromeVersion(revision):
22 """Determines if a revision is a chrome version."""
23 if _CHROME_VERSION_PATTERN.match(revision):
24 return True
25
26 return False
27
14 28
15 class DEPSDownloader(deps_parser.DEPSLoader): 29 class DEPSDownloader(deps_parser.DEPSLoader):
16 """Downloads DEPS from remote Git repo.""" 30 """Downloads DEPS from remote Git repo."""
31
17 def __init__(self, check_deps_git_first=False): 32 def __init__(self, check_deps_git_first=False):
18 """ 33 """
19 Args: 34 Args:
20 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. 35 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS.
21 """ 36 """
22 self.check_deps_git_first = check_deps_git_first 37 self.check_deps_git_first = check_deps_git_first
23 38
24 def Load(self, repo_url, revision, deps_file): 39 def Load(self, repo_url, revision, deps_file):
25 http_client = http_client_appengine.HttpClientAppengine() 40 http_client = http_client_appengine.HttpClientAppengine()
26 repo = git_repository.GitRepository(repo_url, http_client) 41 repo = git_repository.GitRepository(repo_url, http_client)
(...skipping 16 matching lines...) Expand all
43 'Failed to pull %s file from %s, at revision %s.' % ( 58 'Failed to pull %s file from %s, at revision %s.' % (
44 deps_file, repo_url, revision)) 59 deps_file, repo_url, revision))
45 60
46 return content 61 return content
47 62
48 63
49 def GetChromeDependency(revision, platform, check_deps_git_first=False): 64 def GetChromeDependency(revision, platform, check_deps_git_first=False):
50 """Returns all dependencies of Chrome as a dict for the given revision and OS. 65 """Returns all dependencies of Chrome as a dict for the given revision and OS.
51 66
52 Args: 67 Args:
53 revision (str): The revision of a Chrome build. 68 revision (str): The revision of a Chrome build, it can be a githash or a
69 chrome version for a official build.
54 platform (str): The target platform of the Chrome build, should be one of 70 platform (str): The target platform of the Chrome build, should be one of
55 'win', 'ios', 'mac', 'unix', 'android', or 'all'. 71 'win', 'ios', 'mac', 'unix', 'android', or 'all'.
56 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS. 72 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS.
57 73
58 Returns: 74 Returns:
59 A map from dependency path to the dependency info. 75 A map from dependency path to the dependency info.
60 """ 76 """
77 deps_repo_info = {'deps_file': 'DEPS'}
78
79 if IsChromeVersion(revision):
80 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.
81 deps_repo_info['deps_repo_revision'] = 'master'
82 deps_repo_info['deps_file'] = 'release/%s/DEPS' % revision
83
61 root_dep = dependency.Dependency( 84 root_dep = dependency.Dependency(
62 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS') 85 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, **deps_repo_info)
63 86
64 deps_parser.UpdateDependencyTree( 87 deps_parser.UpdateDependencyTree(
65 root_dep, [platform], DEPSDownloader(check_deps_git_first)) 88 root_dep, [platform], DEPSDownloader(check_deps_git_first))
66 89
67 dependencies = {} 90 dependencies = {}
68 91
69 # Flatten the dependency tree into a one-level dict. 92 # Flatten the dependency tree into a one-level dict.
70 def FlattenDepTree(dep): 93 def FlattenDepTree(dep):
71 dependencies[dep.path] = dep 94 dependencies[dep.path] = dep
72 for child in dep.children.values(): 95 for child in dep.children.values():
73 FlattenDepTree(child) 96 FlattenDepTree(child)
74 97
75 FlattenDepTree(root_dep) 98 FlattenDepTree(root_dep)
76 99
77 return dependencies 100 return dependencies
78 101
79 102
80 def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, 103 def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform,
81 check_deps_git_first=False): 104 check_deps_git_first=False, skip_chromium_roll=True):
82 """Returns a list of dependency rolls between the given Chromium revisions. 105 """Returns a list of dependency rolls between the given Chromium revisions.
83 106
84 Args: 107 Args:
85 old_cr_revision (str): The Git commit hash for the old Chromium revision. 108 old_cr_revision (str): The old Chromium revision, it can be a githash or a
86 new_cr_revision (str): The Git commit hash for the new Chromium revision. 109 chrome version for a official build.
110 new_cr_revision (str): The new Chromium revision, it can be a githash or a
111 chrome version for a official build.
87 platform (str): The target OS platform of the Chrome or test binary. 112 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. 113 check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS.
114 skip_chromium_roll (bool): If False, chromium roll will be contained in
115 the return.
116
117 Returns:
118 A list of DependencyRoll objects in the revision range.
89 """ 119 """
90 old_deps = GetChromeDependency( 120 old_deps = GetChromeDependency(
91 old_cr_revision, platform, check_deps_git_first) 121 old_cr_revision, platform, check_deps_git_first)
92 new_deps = GetChromeDependency( 122 new_deps = GetChromeDependency(
93 new_cr_revision, platform, check_deps_git_first) 123 new_cr_revision, platform, check_deps_git_first)
94 124
95 rolls = [] 125 rolls = []
96 126
97 for path, new_dep in new_deps.iteritems(): 127 for path, new_dep in new_deps.iteritems():
98 if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium. 128 if skip_chromium_roll and path == _CHROMIUM_ROOT_DIR:
99 continue 129 continue
100 130
101 old_revision = None 131 old_revision = None
102 if path in old_deps: 132 if path in old_deps:
103 old_revision = old_deps[path].revision 133 old_revision = old_deps[path].revision
104 134
105 if old_revision != new_dep.revision: 135 if old_revision != new_dep.revision:
106 rolls.append( 136 rolls.append(
107 dependency.DependencyRoll( 137 dependency.DependencyRoll(
108 path, new_dep.repo_url, old_revision, new_dep.revision)) 138 path, new_dep.repo_url, old_revision, new_dep.revision))
109 139
110 for path, old_dep in old_deps.iteritems(): 140 for path, old_dep in old_deps.iteritems():
111 if path not in new_deps: 141 if path not in new_deps:
112 rolls.append( 142 rolls.append(
113 dependency.DependencyRoll( 143 dependency.DependencyRoll(
114 path, old_dep.repo_url, old_dep.revision, None)) 144 path, old_dep.repo_url, old_dep.revision, None))
115 145
116 return rolls 146 return rolls
117 147
118 148
119 def GetDEPSRollsDict(old_cr_revision, new_cr_revision, platform): 149 def GetDEPSRollsDict(old_cr_revision, new_cr_revision, platform):
120 """Gets dep_path to DependencyRoll dictionary for deps in 150 """Gets dep_path to DependencyRoll dictionary for deps between revisions.
121 (old_cr_revision, new_cr_revision].
122 151
123 Args: 152 Args:
124 old_cr_revision (str): The Git commit hash for the old Chromium revision. 153 old_cr_revision (str): The old Chromium revision, it can be a githash or a
125 new_cr_revision (str): The Git commit hash for the new Chromium revision. 154 chrome version for a official build.
155 new_cr_revision (str): The new Chromium revision, it can be a githash or a
156 chrome version for a official build.
126 platform (str): The target OS platform of the Chrome or test binary. 157 platform (str): The target OS platform of the Chrome or test binary.
127 158
128 Returns: 159 Returns:
129 A dict, mapping dep path to DependencyRoll. 160 A dict, mapping dep path to its DependencyRoll.
130 """ 161 """
131 deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform) 162 deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform,
132 # Add chromium as dependency roll. 163 skip_chromium_roll=False)
133 deps_rolls.append(dependency.DependencyRoll(
134 _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER,
135 old_cr_revision, new_cr_revision))
136 164
137 deps_rolls_dict = {} 165 deps_rolls_dict = {}
138 for dep_roll in deps_rolls: 166 for dep_roll in deps_rolls:
139 deps_rolls_dict[dep_roll.path] = dep_roll 167 deps_rolls_dict[dep_roll.path] = dep_roll
140 168
141 return deps_rolls_dict 169 return deps_rolls_dict
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/common/dependency.py » ('j') | appengine/findit/common/http_client_appengine.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698