| 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 """Common steps for recipes that use repo for source control.""" | 5 """Common steps for recipes that use repo for source control.""" |
| 6 | 6 |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 from recipe_engine import recipe_api | 9 from recipe_engine import recipe_api |
| 10 | 10 |
| 11 class RepoApi(recipe_api.RecipeApi): | 11 class RepoApi(recipe_api.RecipeApi): |
| 12 """Provides methods to encapsulate repo operations.""" | 12 """Provides methods to encapsulate repo operations.""" |
| 13 | 13 |
| 14 _REPO_LIST_RE = re.compile(r'^(.+) : (.+)$') | 14 _REPO_LIST_RE = re.compile(r'^(.+) : (.+)$') |
| 15 | 15 |
| 16 # WARNING: The version of repo checked into depot_tools doesn't support | 16 # WARNING: The version of repo checked into depot_tools doesn't support |
| 17 # switching between branches correctly due to | 17 # switching between branches correctly due to |
| 18 # https://code.google.com/p/git-repo/issues/detail?id=46 | 18 # https://code.google.com/p/git-repo/issues/detail?id=46 |
| 19 | 19 |
| 20 def __init__(self, **kwargs): | 20 def __init__(self, **kwargs): |
| 21 super(RepoApi, self).__init__(**kwargs) | 21 super(RepoApi, self).__init__(**kwargs) |
| 22 self._repo_path = None | 22 self._repo_path = None |
| 23 | 23 |
| 24 @property | 24 @property |
| 25 def repo_path(self): | 25 def repo_path(self): |
| 26 if not self._repo_path: | 26 if not self._repo_path: |
| 27 self._repo_path = self.m.infra_paths['depot_tools'].join('repo') | 27 self._repo_path = self.m.path['depot_tools'].join('repo') |
| 28 return self._repo_path | 28 return self._repo_path |
| 29 | 29 |
| 30 def __call__(self, args, name=None, **kwargs): | 30 def __call__(self, args, name=None, **kwargs): |
| 31 """Executes 'repo' with the supplied arguments. | 31 """Executes 'repo' with the supplied arguments. |
| 32 | 32 |
| 33 Args: | 33 Args: |
| 34 args: (list): A list of arguments to supply to 'repo'. | 34 args: (list): A list of arguments to supply to 'repo'. |
| 35 name (str): The name of the step. If None, generate a name from the args. | 35 name (str): The name of the step. If None, generate a name from the args. |
| 36 kwargs: Keyword arguments to pass to the 'step' call. | 36 kwargs: Keyword arguments to pass to the 'step' call. |
| 37 Returns: | 37 Returns: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 match = self._REPO_LIST_RE.match(line) | 81 match = self._REPO_LIST_RE.match(line) |
| 82 if match: | 82 if match: |
| 83 result.append(match.groups()) | 83 result.append(match.groups()) |
| 84 | 84 |
| 85 # Display the result in the step text. | 85 # Display the result in the step text. |
| 86 if result: | 86 if result: |
| 87 step_result.presentation.step_text = '</br></br>' | 87 step_result.presentation.step_text = '</br></br>' |
| 88 step_result.presentation.step_text += '</br>'.join( | 88 step_result.presentation.step_text += '</br>'.join( |
| 89 '%s : %s' % (path, name) for path, name in result) | 89 '%s : %s' % (path, name) for path, name in result) |
| 90 return result | 90 return result |
| OLD | NEW |