| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 | 7 |
| 8 class RevisionResolver(object): | 8 class RevisionResolver(object): |
| 9 """Resolves the revision based on build properties.""" | 9 """Resolves the revision based on build properties.""" |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 def resolve_revision(self, revision): | 127 def resolve_revision(self, revision): |
| 128 if hasattr(revision, 'resolve'): | 128 if hasattr(revision, 'resolve'): |
| 129 return revision.resolve(self.m.properties) | 129 return revision.resolve(self.m.properties) |
| 130 return revision | 130 return revision |
| 131 | 131 |
| 132 def sync(self, cfg, with_branch_heads=False, **kwargs): | 132 def sync(self, cfg, with_branch_heads=False, **kwargs): |
| 133 revisions = [] | 133 revisions = [] |
| 134 self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg) | 134 self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg) |
| 135 for i, s in enumerate(cfg.solutions): | 135 for i, s in enumerate(cfg.solutions): |
| 136 if s.safesync_url: # prefer safesync_url in gclient mode | 136 if s.safesync_url: # pragma: no cover |
| 137 continue | 137 continue # prefer safesync_url in gclient mode |
| 138 if i == 0 and s.revision is None: | 138 if i == 0 and s.revision is None: |
| 139 s.revision = RevisionFallbackChain() | 139 s.revision = RevisionFallbackChain() |
| 140 | 140 |
| 141 if s.revision is not None and s.revision != '': | 141 if s.revision is not None and s.revision != '': |
| 142 fixed_revision = self.resolve_revision(s.revision) | 142 fixed_revision = self.resolve_revision(s.revision) |
| 143 if fixed_revision: | 143 if fixed_revision: |
| 144 revisions.extend(['--revision', '%s@%s' % (s.name, fixed_revision)]) | 144 revisions.extend(['--revision', '%s@%s' % (s.name, fixed_revision)]) |
| 145 | 145 |
| 146 for name, revision in sorted(cfg.revisions.items()): | 146 for name, revision in sorted(cfg.revisions.items()): |
| 147 fixed_revision = self.resolve_revision(revision) | 147 fixed_revision = self.resolve_revision(revision) |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 """Updates config revision corresponding to patch_project. | 334 """Updates config revision corresponding to patch_project. |
| 335 | 335 |
| 336 Useful for bot_update only, as this is the only consumer of gclient's config | 336 Useful for bot_update only, as this is the only consumer of gclient's config |
| 337 revision map. This doesn't overwrite the revision if it was already set. | 337 revision map. This doesn't overwrite the revision if it was already set. |
| 338 """ | 338 """ |
| 339 assert patch_project is None or isinstance(patch_project, basestring) | 339 assert patch_project is None or isinstance(patch_project, basestring) |
| 340 cfg = gclient_config or self.c | 340 cfg = gclient_config or self.c |
| 341 path, revision = cfg.patch_projects.get(patch_project, (None, None)) | 341 path, revision = cfg.patch_projects.get(patch_project, (None, None)) |
| 342 if path and revision and path not in cfg.revisions: | 342 if path and revision and path not in cfg.revisions: |
| 343 cfg.revisions[path] = revision | 343 cfg.revisions[path] = revision |
| OLD | NEW |