OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 import urlparse | |
6 | |
7 from recipe_engine import recipe_api | |
8 | |
9 class RietveldApi(recipe_api.RecipeApi): | |
10 def calculate_issue_root(self, extra_patch_project_roots=None): | |
11 """Returns path where a patch should be applied to based on "patch_project". | |
12 | |
13 Maps Rietveld's "patch_project" to a path of directories relative to | |
14 api.gclient.c.solutions[0].name which describe where to place the patch. | |
15 | |
16 Args: | |
17 extra_patch_project_roots: Dict mapping project names to relative roots. | |
18 | |
19 Returns: | |
20 Relative path or empty string if patch_project is not set or path for a | |
21 given is unknown. | |
22 """ | |
23 # Property 'patch_project' is set by Rietveld, 'project' is set by git-try | |
24 # when TRYSERVER_PROJECT is present in codereview.settings. | |
25 patch_project = (self.m.properties.get('patch_project') or | |
26 self.m.properties.get('project')) | |
27 | |
28 # Please avoid adding projects into this hard-coded list unless your project | |
29 # CLs are being run by multiple recipes. Instead pass patch_project_roots to | |
30 # ensure_checkout. | |
31 patch_project_roots = { | |
32 'angle/angle': ['third_party', 'angle'], | |
33 'blink': ['third_party', 'WebKit'], | |
34 'v8': ['v8'], | |
35 'luci-py': ['luci'], | |
36 'recipes-py': ['recipes-py'], | |
37 } | |
38 | |
39 # Make sure to update common projects (above) with extra projects (and not | |
40 # vice versa, so that recipes can override default values if needed. | |
41 if extra_patch_project_roots: | |
42 patch_project_roots.update(extra_patch_project_roots) | |
43 | |
44 path_parts = patch_project_roots.get(patch_project) | |
45 return self.m.path.join(*path_parts) if path_parts else '' | |
OLD | NEW |