Commit 3c2e098b authored by Paweł Hajdan, Jr's avatar Paweł Hajdan, Jr Committed by Commit Bot

Pass cwd via context rather than api.step kwargs

See https://groups.google.com/a/chromium.org/d/msg/infra-dev/p8Iq9v9Y4k0/w__b1zTWAQAJ
for more context.

BUG=685746

Change-Id: Iab46d78e92d67e9a2523cce8b22d9798a6121dd8
Reviewed-on: https://chromium-review.googlesource.com/439328
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
parent 4dbec672
......@@ -5,5 +5,5 @@ deps {
project_id: "recipe_engine"
url: "https://chromium.googlesource.com/external/github.com/luci/recipes-py.git"
branch: "master"
revision: "32e585682faac9148b8760742148d8222ef68a94"
revision: "e8470584a8a0a7a00541b1ab57e48f2793795743"
}
......@@ -306,7 +306,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
# first solution.
if step_result.json.output['did_run']:
co_root = step_result.json.output['root']
cwd = kwargs.get('cwd', self.m.path['start_dir'])
cwd = self.m.step.get_from_context('cwd', self.m.path['start_dir'])
if 'checkout' not in self.m.path:
self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
......
......@@ -248,9 +248,12 @@ class GclientApi(recipe_api.RecipeApi):
def runhooks(self, args=None, name='runhooks', **kwargs):
args = args or []
assert isinstance(args, (list, tuple))
kwargs.setdefault('cwd', self.m.path['checkout'])
return self(
name, ['runhooks'] + list(args), infra_step=False, **kwargs)
context = {}
if not self.m.step.get_from_context('cwd') and self.m.path['checkout']:
context['cwd'] = self.m.path['checkout']
with self.m.step.context(context):
return self(
name, ['runhooks'] + list(args), infra_step=False, **kwargs)
@property
def is_blink_mode(self):
......
......@@ -6,6 +6,7 @@ DEPS = [
'gclient',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/step',
]
......@@ -80,10 +81,11 @@ def RunSteps(api):
bl_cfg.revisions['src/third_party/angle'] = 'refs/heads/lkgr'
bl_cfg.got_revision_mapping['src/blatley'] = 'got_blatley_revision'
api.gclient.checkout(
gclient_config=bl_cfg,
with_branch_heads=True,
cwd=api.path['start_dir'].join('src', 'third_party'))
with api.step.context({
'cwd': api.path['start_dir'].join('src', 'third_party')}):
api.gclient.checkout(
gclient_config=bl_cfg,
with_branch_heads=True)
api.gclient.break_locks()
......
This diff is collapsed.
......@@ -59,7 +59,8 @@ def RunSteps(api):
# If you need to run more arbitrary git commands, you can use api.git itself,
# which behaves like api.step(), but automatically sets the name of the step.
api.git('status', cwd=api.path['checkout'])
with api.step.context({'cwd': api.path['checkout']}):
api.git('status')
api.git('status', name='git status can_fail_build',
can_fail_build=True)
......
......@@ -14,12 +14,12 @@ class GitClApi(recipe_api.RecipeApi):
if kwargs.get('suffix'):
name = name + ' (%s)' % kwargs.pop('suffix')
if 'cwd' not in kwargs:
kwargs['cwd'] = (self.c and self.c.repo_location) or None
return self.m.step(
name, [self.package_repo_resource('git_cl.py'), subcmd] + args,
**kwargs)
with self.m.step.context({
'cwd': self.m.step.get_from_context(
'cwd', (self.c and self.c.repo_location) or None)}):
return self.m.step(
name, [self.package_repo_resource('git_cl.py'), subcmd] + args,
**kwargs)
def get_description(self, patch=None, codereview=None, **kwargs):
args = ['-d']
......
......@@ -84,12 +84,10 @@ class TryserverApi(recipe_api.RecipeApi):
patch_path = patch_dir.join('patch.diff')
self.m.python('patch git setup', git_setup_py, git_setup_args)
self.m.git('fetch', 'origin', patch_ref,
name='patch fetch', cwd=patch_dir)
self.m.git('clean', '-f', '-d', '-x',
name='patch clean', cwd=patch_dir)
self.m.git('checkout', '-f', 'FETCH_HEAD',
name='patch git checkout', cwd=patch_dir)
with self.m.step.context({'cwd': patch_dir}):
self.m.git('fetch', 'origin', patch_ref, name='patch fetch')
self.m.git('clean', '-f', '-d', '-x', name='patch clean')
self.m.git('checkout', '-f', 'FETCH_HEAD', name='patch git checkout')
self._apply_patch_step(patch_file=patch_path, root=cwd)
self.m.step('remove patch', ['rm', '-rf', patch_dir])
......@@ -140,14 +138,15 @@ class TryserverApi(recipe_api.RecipeApi):
# removed.
if patch_root is None:
return self._old_get_files_affected_by_patch()
if not kwargs.get('cwd'):
kwargs['cwd'] = self.m.path['start_dir'].join(patch_root)
step_result = self.m.git('diff', '--cached', '--name-only',
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'),
**kwargs)
with self.m.step.context({
'cwd': self.m.step.get_from_context(
'cwd', self.m.path['start_dir'].join(patch_root))}):
step_result = self.m.git('diff', '--cached', '--name-only',
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'),
**kwargs)
paths = [self.m.path.join(patch_root, p) for p in
step_result.stdout.split()]
if self.m.platform.is_win:
......@@ -159,16 +158,16 @@ class TryserverApi(recipe_api.RecipeApi):
def _old_get_files_affected_by_patch(self):
git_diff_kwargs = {}
context = {}
issue_root = self.m.rietveld.calculate_issue_root()
if issue_root:
git_diff_kwargs['cwd'] = self.m.path['checkout'].join(issue_root)
step_result = self.m.git('diff', '--cached', '--name-only',
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'),
**git_diff_kwargs)
context['cwd'] = self.m.path['checkout'].join(issue_root)
with self.m.step.context(context):
step_result = self.m.git('diff', '--cached', '--name-only',
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 = step_result.stdout.split()
if issue_root:
paths = [self.m.path.join(issue_root, path) for path in paths]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment