| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import collections | 5 import collections |
| 6 import contextlib | 6 import contextlib |
| 7 import hashlib | 7 import hashlib |
| 8 | 8 |
| 9 from recipe_engine import recipe_api | 9 from recipe_engine import recipe_api |
| 10 | 10 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 self.m.rietveld.calculate_issue_root(), | 142 self.m.rietveld.calculate_issue_root(), |
| 143 authentication=authentication) | 143 authentication=authentication) |
| 144 elif storage == PATCH_STORAGE_SVN: | 144 elif storage == PATCH_STORAGE_SVN: |
| 145 return self.apply_from_svn(cwd) | 145 return self.apply_from_svn(cwd) |
| 146 elif storage == PATCH_STORAGE_GIT: | 146 elif storage == PATCH_STORAGE_GIT: |
| 147 return self.apply_from_git(cwd) | 147 return self.apply_from_git(cwd) |
| 148 else: | 148 else: |
| 149 # Since this method is "maybe", we don't raise an Exception. | 149 # Since this method is "maybe", we don't raise an Exception. |
| 150 pass | 150 pass |
| 151 | 151 |
| 152 def get_files_affected_by_patch(self, patch_root=None): | 152 def get_files_affected_by_patch(self, patch_root=None, **kwargs): |
| 153 """Returns list of paths to files affected by the patch. | 153 """Returns list of paths to files affected by the patch. |
| 154 | 154 |
| 155 Argument: | 155 Argument: |
| 156 patch_root: path relative to api.path['root'], usually obtained from | 156 patch_root: path relative to api.path['root'], usually obtained from |
| 157 api.gclient.calculate_patch_root(patch_project) | 157 api.gclient.calculate_patch_root(patch_project) |
| 158 | 158 |
| 159 Returned paths will be relative to to patch_root. | 159 Returned paths will be relative to to patch_root. |
| 160 | 160 |
| 161 TODO(tandrii): remove this doc. | 161 TODO(tandrii): remove this doc. |
| 162 Unless you use patch_root=None, in which case old behavior is used | 162 Unless you use patch_root=None, in which case old behavior is used |
| 163 which returns paths relative to checkout aka solution[0].name. | 163 which returns paths relative to checkout aka solution[0].name. |
| 164 """ | 164 """ |
| 165 # patch_root must be set! None is for backwards compataibility and will be | 165 # patch_root must be set! None is for backwards compataibility and will be |
| 166 # removed. | 166 # removed. |
| 167 if patch_root is None: | 167 if patch_root is None: |
| 168 return self._old_get_files_affected_by_patch() | 168 return self._old_get_files_affected_by_patch() |
| 169 if not kwargs.get('cwd'): |
| 170 kwargs['cwd'] = self.m.path['slave_build'].join(patch_root) |
| 169 step_result = self.m.git('diff', '--cached', '--name-only', | 171 step_result = self.m.git('diff', '--cached', '--name-only', |
| 170 cwd=self.m.path['slave_build'].join(patch_root), | |
| 171 name='git diff to analyze patch', | 172 name='git diff to analyze patch', |
| 172 stdout=self.m.raw_io.output(), | 173 stdout=self.m.raw_io.output(), |
| 173 step_test_data=lambda: | 174 step_test_data=lambda: |
| 174 self.m.raw_io.test_api.stream_output('foo.cc')) | 175 self.m.raw_io.test_api.stream_output('foo.cc'), |
| 176 **kwargs) |
| 175 paths = [self.m.path.join(patch_root, p) for p in | 177 paths = [self.m.path.join(patch_root, p) for p in |
| 176 step_result.stdout.split()] | 178 step_result.stdout.split()] |
| 177 if self.m.platform.is_win: | 179 if self.m.platform.is_win: |
| 178 # Looks like "analyze" wants POSIX slashes even on Windows (since git | 180 # Looks like "analyze" wants POSIX slashes even on Windows (since git |
| 179 # uses that format even on Windows). | 181 # uses that format even on Windows). |
| 180 paths = [path.replace('\\', '/') for path in paths] | 182 paths = [path.replace('\\', '/') for path in paths] |
| 181 step_result.presentation.logs['files'] = paths | 183 step_result.presentation.logs['files'] = paths |
| 182 return paths | 184 return paths |
| 183 | 185 |
| 184 | 186 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 result = self.m.python( | 304 result = self.m.python( |
| 303 'parse description', self.package_repo_resource('git_footers.py'), | 305 'parse description', self.package_repo_resource('git_footers.py'), |
| 304 args=['--json', self.m.json.output()], | 306 args=['--json', self.m.json.output()], |
| 305 stdin=self.m.raw_io.input(data=patch_text)) | 307 stdin=self.m.raw_io.input(data=patch_text)) |
| 306 return result.json.output | 308 return result.json.output |
| 307 | 309 |
| 308 def get_footer(self, tag, patch_text=None): | 310 def get_footer(self, tag, patch_text=None): |
| 309 """Gets a specific tag from a CL description""" | 311 """Gets a specific tag from a CL description""" |
| 310 return self.get_footers(patch_text).get(tag, []) | 312 return self.get_footers(patch_text).get(tag, []) |
| 311 | 313 |
| OLD | NEW |