| 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 difflib | 6 import difflib |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import operator | 9 import operator |
| 10 import os | 10 import os |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 def __eq__(self, other): | 296 def __eq__(self, other): |
| 297 if not isinstance(other, type(self)): | 297 if not isinstance(other, type(self)): |
| 298 return False | 298 return False |
| 299 return self._components() == other._components() | 299 return self._components() == other._components() |
| 300 | 300 |
| 301 | 301 |
| 302 class PathRepoSpec(RepoSpec): | 302 class PathRepoSpec(RepoSpec): |
| 303 """A RepoSpec implementation that uses a local filesystem path.""" | 303 """A RepoSpec implementation that uses a local filesystem path.""" |
| 304 | 304 |
| 305 def __init__(self, project_id, path): | 305 def __init__(self, project_id, path): |
| 306 assert os.path.isabs(path), path |
| 306 self.project_id = project_id | 307 self.project_id = project_id |
| 307 self.path = path | 308 self.path = path |
| 308 | 309 |
| 309 def __str__(self): | 310 def __str__(self): |
| 310 return ( | 311 return ( |
| 311 'PathRepoSpec{project_id="%(project_id)s", path="%(path)s"}' | 312 'PathRepoSpec{project_id="%(project_id)s", path="%(path)s"}' |
| 312 % self.__dict__ | 313 % self.__dict__ |
| 313 ) | 314 ) |
| 314 | 315 |
| 315 def checkout(self, context): | 316 def checkout(self, context): |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 overrides=None): | 616 overrides=None): |
| 616 """Creates a PackageDeps object. | 617 """Creates a PackageDeps object. |
| 617 | 618 |
| 618 Arguments: | 619 Arguments: |
| 619 repo_root: the root of the repository containing this package. | 620 repo_root: the root of the repository containing this package. |
| 620 proto_file: a ProtoFile object corresponding to the repos recipes.cfg | 621 proto_file: a ProtoFile object corresponding to the repos recipes.cfg |
| 621 allow_fetch: whether to fetch dependencies rather than just checking for | 622 allow_fetch: whether to fetch dependencies rather than just checking for |
| 622 them. | 623 them. |
| 623 overrides: if not None, a dictionary of project overrides. Dictionary keys | 624 overrides: if not None, a dictionary of project overrides. Dictionary keys |
| 624 are the `project_id` field to override, and dictionary values | 625 are the `project_id` field to override, and dictionary values |
| 625 are the override path. | 626 are the absolute override path. |
| 626 """ | 627 """ |
| 627 context = PackageContext.from_proto_file(repo_root, proto_file, allow_fetch, | 628 context = PackageContext.from_proto_file(repo_root, proto_file, allow_fetch, |
| 628 deps_path=deps_path) | 629 deps_path=deps_path) |
| 629 | 630 |
| 630 if overrides: | 631 if overrides: |
| 631 overrides = {project_id: PathRepoSpec(project_id, path) | 632 overrides = {project_id: PathRepoSpec(project_id, path) |
| 632 for project_id, path in overrides.iteritems()} | 633 for project_id, path in overrides.iteritems()} |
| 633 package_deps = cls(context, overrides=overrides) | 634 package_deps = cls(context, overrides=overrides) |
| 634 | 635 |
| 635 package_deps._root_package = package_deps._create_package( | 636 package_deps._root_package = package_deps._create_package( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 >>> d = { 'x': 1, 'y': 2 } | 693 >>> d = { 'x': 1, 'y': 2 } |
| 693 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) | 694 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) |
| 694 [('x', 1), ('y', 3), ('z', 4)] | 695 [('x', 1), ('y', 3), ('z', 4)] |
| 695 >>> sorted(d.items()) | 696 >>> sorted(d.items()) |
| 696 [('x', 1), ('y', 2)] | 697 [('x', 1), ('y', 2)] |
| 697 """ | 698 """ |
| 698 | 699 |
| 699 d = copy.copy(d) | 700 d = copy.copy(d) |
| 700 d.update(updates) | 701 d.update(updates) |
| 701 return d | 702 return d |
| OLD | NEW |