OLD | NEW |
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 | 5 import re |
6 | 6 |
| 7 # N.B., in order for our mocking framework to work correctly, we *must not* |
| 8 # import the GitRepository class directly; instead, we must only import |
| 9 # the git_repository module and then rely on dynamic dispatch to resolve |
| 10 # the module's GitRepository attribute. Otherwise the DEPSDownloader.Load |
| 11 # method will hold a reference directly to the real GitRepository class, |
| 12 # which means we can't swap it out for the DummyGitRepository class, which |
| 13 # in turn will cause some unit tests to fail (since we can't mock the |
| 14 # responses of doing SSL stuff). |
| 15 from lib.gitiles import git_repository |
7 from common import dependency | 16 from common import dependency |
8 from common import deps_parser | 17 from common import deps_parser |
9 from common import git_repository | |
10 from common import http_client_appengine | 18 from common import http_client_appengine |
11 | 19 |
12 | 20 |
13 _CHROMIUM_ROOT_DIR = 'src/' | 21 _CHROMIUM_ROOT_DIR = 'src/' |
14 _CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git' | 22 _CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git' |
15 | 23 |
16 _CHROME_VERSION_PATTERN = re.compile(r'^\d+\.\d+\.\d+\.\d+$') | 24 _CHROME_VERSION_PATTERN = re.compile(r'^\d+\.\d+\.\d+\.\d+$') |
17 | 25 |
18 _BUILDSPEC_REPO = ('https://chrome-internal.googlesource.com/chrome/tools/' | 26 _BUILDSPEC_REPO = ('https://chrome-internal.googlesource.com/chrome/tools/' |
19 'buildspec.git/') | 27 'buildspec.git/') |
20 | 28 |
21 | 29 |
22 def IsChromeVersion(revision): | 30 def IsChromeVersion(revision): |
23 """Determines if a revision is a chrome version.""" | 31 """Determines if a revision is a chrome version.""" |
24 if _CHROME_VERSION_PATTERN.match(revision): | 32 if _CHROME_VERSION_PATTERN.match(revision): |
25 return True | 33 return True |
26 | 34 |
27 return False | 35 return False |
28 | 36 |
29 | 37 |
30 class DEPSDownloader(deps_parser.DEPSLoader): | 38 class DEPSDownloader(deps_parser.DEPSLoader): |
31 """Downloads DEPS from remote Git repo.""" | 39 """Downloads DEPS from remote Git repo.""" |
32 | 40 |
| 41 # TODO(wrengr): why do we allocate a new GitRepository every time |
| 42 # we call Load, rather than just doing it once and saving it in the |
| 43 # DEPSDownloader class (via RAII)? |
33 def Load(self, repo_url, revision, deps_file): | 44 def Load(self, repo_url, revision, deps_file): |
34 http_client = http_client_appengine.HttpClientAppengine() | 45 http_client = http_client_appengine.HttpClientAppengine() |
35 repo = git_repository.GitRepository(repo_url, http_client) | 46 repo = git_repository.GitRepository(repo_url, http_client) |
36 | 47 |
37 content = None | 48 content = None |
38 if deps_file == 'DEPS' and repo_url == _CHROMIUM_REPO_MASTER: | 49 if deps_file == 'DEPS' and repo_url == _CHROMIUM_REPO_MASTER: |
39 # Try .DEPS.git instead of DEPS first, for commits during the Git chaos. | 50 # Try .DEPS.git instead of DEPS first, for commits during the Git chaos. |
40 content = repo.GetSource('.DEPS.git', revision) | 51 content = repo.GetSource('.DEPS.git', revision) |
41 | 52 |
42 if content is None: | 53 if content is None: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 """ | 168 """ |
158 deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, | 169 deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform, |
159 skip_chromium_roll=False) | 170 skip_chromium_roll=False) |
160 | 171 |
161 deps_rolls_dict = {} | 172 deps_rolls_dict = {} |
162 | 173 |
163 for dep_roll in deps_rolls: | 174 for dep_roll in deps_rolls: |
164 deps_rolls_dict[dep_roll.path] = dep_roll | 175 deps_rolls_dict[dep_roll.path] = dep_roll |
165 | 176 |
166 return deps_rolls_dict | 177 return deps_rolls_dict |
OLD | NEW |