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

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

Powered by Google App Engine
This is Rietveld 408576698