summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-09-11 18:22:01 +0100
committerJames Ennis <james.ennis@codethink.co.uk>2019-09-11 18:23:04 +0100
commit1e0a9cd13ea30a19bd5a8c2a0ee79d4568242fa9 (patch)
treeb54911cc6d656fbda5b6d5accc91b91034898d9e
parent1c4fc0277245a6d1fa206aa03ff32bce7041ea77 (diff)
downloadbuildstream-jennis/pull_implicitly_in_checkout.tar.gz
cli.py: Change artifact checkout to pull implicitlyjennis/pull_implicitly_in_checkout
This makes it consistent with source checkout
-rw-r--r--src/buildstream/_frontend/cli.py5
-rw-r--r--src/buildstream/_stream.py6
-rw-r--r--tests/frontend/buildcheckout.py12
3 files changed, 8 insertions, 15 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 6f409166e..02133fe59 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -1052,15 +1052,13 @@ def artifact_show(app, deps, artifacts):
@click.option('--compression', default=None,
type=click.Choice(['gz', 'xz', 'bz2']),
help="The compression option of the tarball created.")
-@click.option('--pull', 'pull_', is_flag=True,
- help="Pull the artifact if it's missing or incomplete.")
@click.option('--directory', default=None,
type=click.Path(file_okay=False),
help="The directory to checkout the artifact to")
@click.argument('target', required=False,
type=click.Path(readable=False))
@click.pass_obj
-def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, pull_, directory, target):
+def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, directory, target):
"""Checkout contents of an artifact
When this command is executed from a workspace directory, the default
@@ -1111,7 +1109,6 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
deps=deps,
integrate=True if integrate is None else integrate,
hardlinks=hardlinks,
- pull=pull_,
compression=compression,
tar=bool(tar))
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index feb3efe9f..64ff3cfe6 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -530,8 +530,6 @@ class Stream():
# will be placed at the given location. If true and
# location is '-', the tarball will be dumped on the
# standard output.
- # pull (bool): If true will attempt to pull any missing or incomplete
- # artifacts.
#
def checkout(self, target, *,
location=None,
@@ -540,7 +538,6 @@ class Stream():
integrate=True,
hardlinks=False,
compression='',
- pull=False,
tar=False):
elements, _ = self._load((target,), (), selection=deps, use_artifact_config=True, load_refs=True)
@@ -553,8 +550,9 @@ class Stream():
self._check_location_writable(location, force=force, tar=tar)
+ # Only try to pull elements which we know are not cached
uncached_elts = [elt for elt in elements if not elt._cached()]
- if uncached_elts and pull:
+ if uncached_elts:
self._message(MessageType.INFO, "Attempting to fetch missing or incomplete artifact")
self._scheduler.clear_queues()
self._add_queue(PullQueue(self._scheduler))
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index c9a42239a..f0fa82151 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -1105,14 +1105,12 @@ def test_partial_artifact_checkout_fetch(cli, datafiles, tmpdir):
os.unlink(objpath)
# Verify that the build-only dependency is not (complete) in the local cache
- result = cli.run(project=project, args=[
- 'artifact', 'checkout', build_elt,
- '--directory', checkout_dir])
- result.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')
+ assert cli.get_element_state(project, build_elt) != 'cached'
- # Verify that the pull method fetches relevant artifacts in order to stage
+ # Verify that when we checkout, we implicitly pull the relevant
+ # artifacts in order to stage
result = cli.run(project=project, args=[
- 'artifact', 'checkout', '--pull', build_elt,
+ 'artifact', 'checkout', build_elt,
'--directory', checkout_dir])
result.assert_success()
@@ -1134,7 +1132,7 @@ def test_partial_checkout_fail(tmpdir, datafiles, cli):
}})
res = cli.run(project=project, args=[
- 'artifact', 'checkout', '--pull', build_elt, '--directory',
+ 'artifact', 'checkout', build_elt, '--directory',
checkout_dir])
res.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')
assert re.findall(r'Remote \((\S+)\) does not have artifact (\S+) cached', res.stderr)