Chromium Code Reviews| Index: recipe_modules/gclient/api.py |
| diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py |
| index 2d9ed949f5f72d6c78cd16552648245fc63fce81..f81f40f9ee728528458d9a6dcc5d4a767549bf47 100644 |
| --- a/recipe_modules/gclient/api.py |
| +++ b/recipe_modules/gclient/api.py |
| @@ -148,6 +148,7 @@ class GclientApi(recipe_api.RecipeApi): |
| def sync(self, cfg, with_branch_heads=False, **kwargs): |
| revisions = [] |
| + self.set_patch_project_revision(cfg) |
|
Michael Achenbach
2016/04/25 12:09:58
Guess this path has no coverage, but never mind...
|
| for i, s in enumerate(cfg.solutions): |
| if s.safesync_url: # prefer safesync_url in gclient mode |
| continue |
| @@ -336,3 +337,41 @@ class GclientApi(recipe_api.RecipeApi): |
| args=[self.m.path['slave_build']], |
| infra_step=True, |
| ) |
| + |
| + def calculate_patch_root(self, patch_project, gclient_config=None): |
| + """Returns path where a patch should be applied to based patch_project. |
| + |
| + Maps "patch_project" to a path of directories relative to checkout's root, |
| + which describe where to place the patch. |
| + |
| + For now, considers only first solution (c.solutions[0]), but in theory can |
| + be extended to all of them. |
| + |
| + See patch_projects solution config property. |
| + |
| + Returns: |
| + Relative path, including solution's root. |
| + If patch_project is not given or not recognized, it'll be just first |
| + solution root. |
| + """ |
| + cfg = gclient_config or self.c |
| + root, _ = cfg.patch_projects.get(patch_project, ('', '')) |
| + if root: |
| + # Note, that c.patch_projects contains patch roots as |
| + # slash(/)-separated path, which are roots of the respective project repos |
| + # and include actual solution name in them. |
| + return self.m.path.join(*root.split('/')) |
| + # Default case - assume patch is for first solution, as this is what most |
| + # projects rely on. |
| + return cfg.solutions[0].name |
| + |
| + def set_patch_project_revision(self, patch_project, gclient_config=None): |
| + """Updates config revision corresponding to patch_project. |
| + |
| + Useful for bot_update only, as this is the only consumer of gclient's config |
| + revision map. |
| + """ |
| + cfg = gclient_config or self.c |
| + path, revision = cfg.patch_projects.get(patch_project, (None, None)) |
| + if path and revision: |
| + cfg.revisions[path] = revision |
|
Michael Achenbach
2016/04/25 12:09:58
This should maybe only be updated if not set alrea
tandrii(chromium)
2016/04/25 13:37:52
Done.
|