| 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 | |
| 284 self.project_id = project_id | 283 self.project_id = project_id |
| 285 self.path = path | 284 self.path = path |
| 286 | 285 |
| 287 def __str__(self): | 286 def __str__(self): |
| 288 return ( | 287 return ( |
| 289 'PathRepoSpec{project_id="%(project_id)s", path="%(path)s"}' | 288 'PathRepoSpec{project_id="%(project_id)s", path="%(path)s"}' |
| 290 % self.__dict__ | 289 % self.__dict__ |
| 291 ) | 290 ) |
| 292 | 291 |
| 293 def fetch(self): | 292 def fetch(self): |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 overrides=None): | 604 overrides=None): |
| 606 """Creates a PackageDeps object. | 605 """Creates a PackageDeps object. |
| 607 | 606 |
| 608 Arguments: | 607 Arguments: |
| 609 repo_root: the root of the repository containing this package. | 608 repo_root: the root of the repository containing this package. |
| 610 package_file: a PackageFile object corresponding to the repos recipes.cfg | 609 package_file: a PackageFile object corresponding to the repos recipes.cfg |
| 611 allow_fetch: whether to fetch dependencies rather than just checking for | 610 allow_fetch: whether to fetch dependencies rather than just checking for |
| 612 them. | 611 them. |
| 613 overrides: if not None, a dictionary of project overrides. Dictionary keys | 612 overrides: if not None, a dictionary of project overrides. Dictionary keys |
| 614 are the `project_id` field to override, and dictionary values | 613 are the `project_id` field to override, and dictionary values |
| 615 are the absolute override path. | 614 are the override path. |
| 616 """ | 615 """ |
| 617 context = PackageContext.from_package_file( | 616 context = PackageContext.from_package_file( |
| 618 repo_root, package_file, allow_fetch, deps_path=deps_path) | 617 repo_root, package_file, allow_fetch, deps_path=deps_path) |
| 619 | 618 |
| 620 if overrides: | 619 if overrides: |
| 621 overrides = {project_id: PathRepoSpec(project_id, path) | 620 overrides = {project_id: PathRepoSpec(project_id, path) |
| 622 for project_id, path in overrides.iteritems()} | 621 for project_id, path in overrides.iteritems()} |
| 623 package_deps = cls(overrides=overrides) | 622 package_deps = cls(overrides=overrides) |
| 624 | 623 |
| 625 if allow_fetch: | 624 if allow_fetch: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 >>> d = { 'x': 1, 'y': 2 } | 689 >>> d = { 'x': 1, 'y': 2 } |
| 691 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) | 690 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) |
| 692 [('x', 1), ('y', 3), ('z', 4)] | 691 [('x', 1), ('y', 3), ('z', 4)] |
| 693 >>> sorted(d.items()) | 692 >>> sorted(d.items()) |
| 694 [('x', 1), ('y', 2)] | 693 [('x', 1), ('y', 2)] |
| 695 """ | 694 """ |
| 696 | 695 |
| 697 d = copy.copy(d) | 696 d = copy.copy(d) |
| 698 d.update(updates) | 697 d.update(updates) |
| 699 return d | 698 return d |
| OLD | NEW |