| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 def resolve_revision(self, revision): | 144 def resolve_revision(self, revision): |
| 145 if hasattr(revision, 'resolve'): | 145 if hasattr(revision, 'resolve'): |
| 146 return revision.resolve(self.m.properties) | 146 return revision.resolve(self.m.properties) |
| 147 return revision | 147 return revision |
| 148 | 148 |
| 149 def sync(self, cfg, with_branch_heads=False, **kwargs): | 149 def sync(self, cfg, with_branch_heads=False, **kwargs): |
| 150 revisions = [] | 150 revisions = [] |
| 151 self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg) | 151 self.set_patch_project_revision(self.m.properties.get('patch_project'), cfg) |
| 152 for i, s in enumerate(cfg.solutions): | 152 for i, s in enumerate(cfg.solutions): |
| 153 if s.safesync_url: # prefer safesync_url in gclient mode | |
| 154 continue | |
| 155 if i == 0 and s.revision is None: | 153 if i == 0 and s.revision is None: |
| 156 s.revision = RevisionFallbackChain() | 154 s.revision = RevisionFallbackChain() |
| 157 | 155 |
| 158 if s.revision is not None and s.revision != '': | 156 if s.revision is not None and s.revision != '': |
| 159 fixed_revision = self.resolve_revision(s.revision) | 157 fixed_revision = self.resolve_revision(s.revision) |
| 160 if fixed_revision: | 158 if fixed_revision: |
| 161 revisions.extend(['--revision', '%s@%s' % (s.name, fixed_revision)]) | 159 revisions.extend(['--revision', '%s@%s' % (s.name, fixed_revision)]) |
| 162 | 160 |
| 163 for name, revision in sorted(cfg.revisions.items()): | 161 for name, revision in sorted(cfg.revisions.items()): |
| 164 fixed_revision = self.resolve_revision(revision) | 162 fixed_revision = self.resolve_revision(revision) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 """Updates config revision corresponding to patch_project. | 368 """Updates config revision corresponding to patch_project. |
| 371 | 369 |
| 372 Useful for bot_update only, as this is the only consumer of gclient's config | 370 Useful for bot_update only, as this is the only consumer of gclient's config |
| 373 revision map. This doesn't overwrite the revision if it was already set. | 371 revision map. This doesn't overwrite the revision if it was already set. |
| 374 """ | 372 """ |
| 375 assert patch_project is None or isinstance(patch_project, basestring) | 373 assert patch_project is None or isinstance(patch_project, basestring) |
| 376 cfg = gclient_config or self.c | 374 cfg = gclient_config or self.c |
| 377 path, revision = cfg.patch_projects.get(patch_project, (None, None)) | 375 path, revision = cfg.patch_projects.get(patch_project, (None, None)) |
| 378 if path and revision and path not in cfg.revisions: | 376 if path and revision and path not in cfg.revisions: |
| 379 cfg.revisions[path] = revision | 377 cfg.revisions[path] = revision |
| OLD | NEW |