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

Unified Diff: recipe_modules/tryserver/api.py

Issue 1927403003: Avoid computing patch_root in get_files_affected_by_patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: review 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
« no previous file with comments | « no previous file | recipe_modules/tryserver/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/tryserver/api.py
diff --git a/recipe_modules/tryserver/api.py b/recipe_modules/tryserver/api.py
index 8bd8df87f94bdfb68e7ad7f91ee0a15f54fec61a..87d12e49131d5cdec0973cdb640faf6e98a3aced 100644
--- a/recipe_modules/tryserver/api.py
+++ b/recipe_modules/tryserver/api.py
@@ -148,7 +148,40 @@ class TryserverApi(recipe_api.RecipeApi):
# Since this method is "maybe", we don't raise an Exception.
pass
- def get_files_affected_by_patch(self):
+ def get_files_affected_by_patch(self, patch_root=None):
+ """Returns list of paths to files affected by the patch.
+
+ Argument:
+ patch_root: path relative to api.path['root'], usually obtained from
+ api.gclient.calculate_patch_root(patch_project)
+
+ Returned paths will be relative to to patch_root.
+
+ TODO(tandrii): remove this doc.
+ Unless you use patch_root=None, in which case old behavior is used
+ which returns paths relative to checkout aka solution[0].name.
+ """
+ # patch_root must be set! None is for backwards compataibility and will be
+ # removed.
+ if patch_root is None:
+ return self._old_get_files_affected_by_patch()
+ step_result = self.m.git('diff', '--cached', '--name-only',
+ cwd=self.m.path['slave_build'].join(patch_root),
+ name='git diff to analyze patch',
+ stdout=self.m.raw_io.output(),
+ step_test_data=lambda:
+ self.m.raw_io.test_api.stream_output('foo.cc'))
+ paths = [self.m.path.join(patch_root, p) for p in
+ step_result.stdout.split()]
+ if self.m.platform.is_win:
+ # Looks like "analyze" wants POSIX slashes even on Windows (since git
+ # uses that format even on Windows).
+ paths = [path.replace('\\', '/') for path in paths]
+ step_result.presentation.logs['files'] = paths
+ return paths
+
+
+ def _old_get_files_affected_by_patch(self):
git_diff_kwargs = {}
issue_root = self.m.rietveld.calculate_issue_root()
if issue_root:
« no previous file with comments | « no previous file | recipe_modules/tryserver/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698