Chromium Code Reviews| Index: recipe_engine/package.py |
| diff --git a/recipe_engine/package.py b/recipe_engine/package.py |
| index 4ada02ac0bd9c7ab3fce47e97ddb0c4d6ae958ef..bc30d4ca0d662a9384f3c8379c705aab1462eaea 100644 |
| --- a/recipe_engine/package.py |
| +++ b/recipe_engine/package.py |
| @@ -169,6 +169,12 @@ class RepoSpec(object): |
| Requires a good checkout.""" |
| return ProtoFile(InfraRepoConfig().to_recipes_cfg(self.repo_root(context))) |
| + def is_consistent_with(self, other): |
| + """Returns True iff |other| can be used in place of |self| while keeping |
| + the dependency graph consistent. Most often it means being pinned at the |
| + same revision, but some specs (like path-based) are always compatible.""" |
| + return (self == other) |
|
iannucci
2017/01/30 17:53:20
the equality operator overload in this file is a b
Paweł Hajdan Jr.
2017/01/30 19:20:05
Done.
|
| + |
| class GitRepoSpec(RepoSpec): |
| def __init__(self, project_id, repo, branch, revision, path, backend): |
| @@ -324,6 +330,13 @@ class PathRepoSpec(RepoSpec): |
| return False |
| return self.path == other.path |
| + def is_consistent_with(self, other): |
| + # PathRepoSpec is always compatible, unless it's PathRepoSpec with a |
| + # different path. |
| + if isinstance(other, type(self)): |
| + return self.path == other.path |
| + return True |
| + |
| class RootRepoSpec(RepoSpec): |
| def __init__(self, proto_file): |
| @@ -654,7 +667,10 @@ class PackageDeps(object): |
| 'Package %s depends on itself' % project_id) |
| # Only enforce package consistency within the override boundary. |
| - if current.is_override == overriding and repo_spec != current.repo_spec: |
| + # It's fine if either spec claims it's consistent with the other. |
| + if (current.is_override == overriding and |
| + not repo_spec.is_consistent_with(current.repo_spec) and |
| + not current.repo_spec.is_consistent_with(repo_spec)): |
| raise InconsistentDependencyGraphError( |
| project_id, (repo_spec, current.repo_spec)) |
| self._packages[project_id] = None |