OLD | NEW |
1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import logging | 6 import logging |
7 import operator | 7 import operator |
8 import os | 8 import os |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 def __eq__(self, other): | 273 def __eq__(self, other): |
274 if not isinstance(other, type(self)): | 274 if not isinstance(other, type(self)): |
275 return False | 275 return False |
276 return self._components() == other._components() | 276 return self._components() == other._components() |
277 | 277 |
278 | 278 |
279 class PathRepoSpec(RepoSpec): | 279 class PathRepoSpec(RepoSpec): |
280 """A RepoSpec implementation that uses a local filesystem path.""" | 280 """A RepoSpec implementation that uses a local filesystem path.""" |
281 | 281 |
282 def __init__(self, project_id, path): | 282 def __init__(self, project_id, path): |
| 283 assert os.path.isabs(path), path |
283 self.project_id = project_id | 284 self.project_id = project_id |
284 self.path = path | 285 self.path = path |
285 | 286 |
286 def __str__(self): | 287 def __str__(self): |
287 return ( | 288 return ( |
288 'PathRepoSpec{project_id="%(project_id)s", path="%(path)s"}' | 289 'PathRepoSpec{project_id="%(project_id)s", path="%(path)s"}' |
289 % self.__dict__ | 290 % self.__dict__ |
290 ) | 291 ) |
291 | 292 |
292 def fetch(self): | 293 def fetch(self): |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 overrides=None): | 605 overrides=None): |
605 """Creates a PackageDeps object. | 606 """Creates a PackageDeps object. |
606 | 607 |
607 Arguments: | 608 Arguments: |
608 repo_root: the root of the repository containing this package. | 609 repo_root: the root of the repository containing this package. |
609 package_file: a PackageFile object corresponding to the repos recipes.cfg | 610 package_file: a PackageFile object corresponding to the repos recipes.cfg |
610 allow_fetch: whether to fetch dependencies rather than just checking for | 611 allow_fetch: whether to fetch dependencies rather than just checking for |
611 them. | 612 them. |
612 overrides: if not None, a dictionary of project overrides. Dictionary keys | 613 overrides: if not None, a dictionary of project overrides. Dictionary keys |
613 are the `project_id` field to override, and dictionary values | 614 are the `project_id` field to override, and dictionary values |
614 are the override path. | 615 are the absolute override path. |
615 """ | 616 """ |
616 context = PackageContext.from_package_file( | 617 context = PackageContext.from_package_file( |
617 repo_root, package_file, allow_fetch, deps_path=deps_path) | 618 repo_root, package_file, allow_fetch, deps_path=deps_path) |
618 | 619 |
619 if overrides: | 620 if overrides: |
620 overrides = {project_id: PathRepoSpec(project_id, path) | 621 overrides = {project_id: PathRepoSpec(project_id, path) |
621 for project_id, path in overrides.iteritems()} | 622 for project_id, path in overrides.iteritems()} |
622 package_deps = cls(overrides=overrides) | 623 package_deps = cls(overrides=overrides) |
623 | 624 |
624 if allow_fetch: | 625 if allow_fetch: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 >>> d = { 'x': 1, 'y': 2 } | 690 >>> d = { 'x': 1, 'y': 2 } |
690 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) | 691 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) |
691 [('x', 1), ('y', 3), ('z', 4)] | 692 [('x', 1), ('y', 3), ('z', 4)] |
692 >>> sorted(d.items()) | 693 >>> sorted(d.items()) |
693 [('x', 1), ('y', 2)] | 694 [('x', 1), ('y', 2)] |
694 """ | 695 """ |
695 | 696 |
696 d = copy.copy(d) | 697 d = copy.copy(d) |
697 d.update(updates) | 698 d.update(updates) |
698 return d | 699 return d |
OLD | NEW |