OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 collections | 5 import collections |
6 | 6 |
7 from dashboard.common import namespaced_stored_object | 7 from dashboard.common import namespaced_stored_object |
8 from dashboard.services import gitiles_service | 8 from dashboard.services import gitiles_service |
9 | 9 |
10 | 10 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 # Translate repository if it's a URL. | 228 # Translate repository if it's a URL. |
229 repository_from_url = _Repository(repository) | 229 repository_from_url = _Repository(repository) |
230 if repository_from_url: | 230 if repository_from_url: |
231 repository = repository_from_url | 231 repository = repository_from_url |
232 | 232 |
233 dep = cls(repository, data['git_hash']) | 233 dep = cls(repository, data['git_hash']) |
234 | 234 |
235 try: | 235 try: |
236 gitiles_service.CommitInfo(dep.repository_url, dep.git_hash) | 236 gitiles_service.CommitInfo(dep.repository_url, dep.git_hash) |
237 except gitiles_service.NotFoundError as e: | 237 except gitiles_service.NotFoundError as e: |
238 raise KeyError(e) | 238 raise KeyError(str(e)) |
239 | 239 |
240 return dep | 240 return dep |
241 | 241 |
242 @classmethod | 242 @classmethod |
243 def Midpoint(cls, dep_a, dep_b): | 243 def Midpoint(cls, dep_a, dep_b): |
244 """Return a Dep halfway between the two given Deps. | 244 """Return a Dep halfway between the two given Deps. |
245 | 245 |
246 Uses Gitiles to look up the commit range. | 246 Uses Gitiles to look up the commit range. |
247 | 247 |
248 Args: | 248 Args: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 repositories = namespaced_stored_object.Get(_REPOSITORIES_KEY) | 309 repositories = namespaced_stored_object.Get(_REPOSITORIES_KEY) |
310 repository = repository_url.split('/')[-1] | 310 repository = repository_url.split('/')[-1] |
311 | 311 |
312 if repository in repositories: | 312 if repository in repositories: |
313 raise AssertionError("Attempted to add a repository that's already in the " | 313 raise AssertionError("Attempted to add a repository that's already in the " |
314 'Datastore: %s: %s' % (repository, repository_url)) | 314 'Datastore: %s: %s' % (repository, repository_url)) |
315 | 315 |
316 repositories[repository] = {'repository_url': repository_url} | 316 repositories[repository] = {'repository_url': repository_url} |
317 namespaced_stored_object.Set(_REPOSITORIES_KEY, repositories) | 317 namespaced_stored_object.Set(_REPOSITORIES_KEY, repositories) |
OLD | NEW |