Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1269)

Unified Diff: recipe_modules/gclient/api.py

Issue 1917433002: Generalize patch_project to patch root conversion. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: recipe_modules/gclient/api.py
diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py
index 2d9ed949f5f72d6c78cd16552648245fc63fce81..41d7e14e8855f5083137f3b33b6620ca8e833f0c 100644
--- a/recipe_modules/gclient/api.py
+++ b/recipe_modules/gclient/api.py
@@ -336,3 +336,28 @@ 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.solutions[0].patch_projects.get(patch_project, ('', ''))
Michael Achenbach 2016/04/25 09:32:42 solutions[0] goes away when making the dict global
tandrii(chromium) 2016/04/25 11:39:50 Done.
+ if root:
+ # Note, that c.solutions[i].patch_projects contains patch roots as
+ # /-separated path, which are roots of the respective project repos.
+ return self.m.path.join(*root.split('/'))
+ # Default case - assume patch is for first solution.
+ return cfg.solutions[0].name

Powered by Google App Engine
This is Rietveld 408576698