Commit fbd15939 authored by James Ennis's avatar James Ennis
Browse files

Mark 'old' checkout command as obsolete

This commit marks 'bst checkout' as a 'hidden' command. If used,
the user will be prompted to use the new 'bst artifact checkout'
command.

All tests which used 'bst checkout' have been modified to use
the new artifact sub-command.

This partially solves #822.
parent 9eefe863
Loading
Loading
Loading
Loading
+27 −61
Original line number Diff line number Diff line
@@ -553,67 +553,6 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command)
    sys.exit(exitcode)


##################################################################
#                        Checkout Command                        #
##################################################################
@cli.command(short_help="Checkout a built artifact")
@click.option('--force', '-f', default=False, is_flag=True,
              help="Allow files to be overwritten")
@click.option('--deps', '-d', default='run',
              type=click.Choice(['run', 'build', 'none']),
              help='The dependencies to checkout (default: run)')
@click.option('--integrate/--no-integrate', default=True, is_flag=True,
              help="Whether to run integration commands")
@click.option('--hardlinks', default=False, is_flag=True,
              help="Checkout hardlinks instead of copies (handle with care)")
@click.option('--tar', default=False, is_flag=True,
              help="Create a tarball from the artifact contents instead "
                   "of a file tree. If LOCATION is '-', the tarball "
                   "will be dumped to the standard output.")
@click.argument('element', required=False,
                type=click.Path(readable=False))
@click.argument('location', type=click.Path(), required=False)
@click.pass_obj
def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
    """Checkout a built artifact to the specified location
    """
    from ..element import Scope

    if not element and not location:
        click.echo("ERROR: LOCATION is not specified", err=True)
        sys.exit(-1)

    if element and not location:
        # Nasty hack to get around click's optional args
        location = element
        element = None

    if hardlinks and tar:
        click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
        sys.exit(-1)

    if deps == "run":
        scope = Scope.RUN
    elif deps == "build":
        scope = Scope.BUILD
    elif deps == "none":
        scope = Scope.NONE

    with app.initialized():
        if not element:
            element = app.context.guess_element()
            if not element:
                raise AppError('Missing argument "ELEMENT".')

        app.stream.checkout(element,
                            location=location,
                            force=force,
                            scope=scope,
                            integrate=integrate,
                            hardlinks=hardlinks,
                            tar=tar)


##################################################################
#                        Source Command                          #
##################################################################
@@ -1206,6 +1145,33 @@ def track(app, elements, deps, except_, cross_junctions):
    sys.exit(1)


##################################################################
#                        Checkout Command                        #
##################################################################
@cli.command(short_help="Checkout a built artifact", hidden=True)
@click.option('--force', '-f', default=False, is_flag=True,
              help="Allow files to be overwritten")
@click.option('--deps', '-d', default='run',
              type=click.Choice(['run', 'build', 'none']),
              help='The dependencies to checkout (default: run)')
@click.option('--integrate/--no-integrate', default=True, is_flag=True,
              help="Whether to run integration commands")
@click.option('--hardlinks', default=False, is_flag=True,
              help="Checkout hardlinks instead of copies (handle with care)")
@click.option('--tar', default=False, is_flag=True,
              help="Create a tarball from the artifact contents instead "
                   "of a file tree. If LOCATION is '-', the tarball "
                   "will be dumped to the standard output.")
@click.argument('element', required=False,
                type=click.Path(readable=False))
@click.argument('location', type=click.Path(), required=False)
@click.pass_obj
def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
    click.echo("This command is now obsolete. Use `bst artifact checkout` instead " +
               "and use the --directory option to specify LOCATION", err=True)
    sys.exit(1)


################################################################
#                          Pull Command                        #
################################################################
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ element="$1"
checkout_tar="bst-checkout-$(basename "$element")-$RANDOM.tar"

echo "INFO: Checking out $element ..." >&2
$bst_cmd checkout --tar "$element" "$checkout_tar" || die "Failed to checkout $element"
$bst_cmd artifact checkout "$element" --tar "$checkout_tar" || die "Failed to checkout $element"
echo "INFO: Successfully checked out $element" >&2

echo "INFO: Importing Docker image ..." >&2
+3 −2
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ def test_expiry_order(cli, datafiles, tmpdir):
    wait_for_cache_granularity()

    # Now extract dep.bst
    res = cli.run(project=project, args=['checkout', 'dep.bst', checkout])
    res = cli.run(project=project, args=['artifact', 'checkout', 'dep.bst', '--directory', checkout])
    res.assert_success()

    # Finally, build something that will cause the cache to overflow
@@ -379,7 +379,8 @@ def test_extract_expiry(cli, datafiles, tmpdir):
    assert cli.get_element_state(project, 'target.bst') == 'cached'

    # Force creating extract
    res = cli.run(project=project, args=['checkout', 'target.bst', os.path.join(str(tmpdir), 'checkout')])
    res = cli.run(project=project, args=['artifact', 'checkout', 'target.bst',
                                         '--directory', os.path.join(str(tmpdir), 'checkout')])
    res.assert_success()

    # Get a snapshot of the extracts in advance
+8 −7
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ def test_filter_include(datafiles, cli, tmpdir):
    result.assert_success()

    checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
    result = cli.run(project=project, args=['checkout', 'output-include.bst', checkout])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-include.bst', '--directory', checkout])
    result.assert_success()
    assert os.path.exists(os.path.join(checkout, "foo"))
    assert not os.path.exists(os.path.join(checkout, "bar"))
@@ -31,7 +31,8 @@ def test_filter_include_dynamic(datafiles, cli, tmpdir):
    result.assert_success()

    checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
    result = cli.run(project=project, args=['checkout', 'output-dynamic-include.bst', checkout])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-dynamic-include.bst',
                                            '--directory', checkout])
    result.assert_success()
    assert os.path.exists(os.path.join(checkout, "foo"))
    assert not os.path.exists(os.path.join(checkout, "bar"))
@@ -44,7 +45,7 @@ def test_filter_exclude(datafiles, cli, tmpdir):
    result.assert_success()

    checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
    result = cli.run(project=project, args=['checkout', 'output-exclude.bst', checkout])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-exclude.bst', '--directory', checkout])
    result.assert_success()
    assert not os.path.exists(os.path.join(checkout, "foo"))
    assert os.path.exists(os.path.join(checkout, "bar"))
@@ -57,7 +58,7 @@ def test_filter_orphans(datafiles, cli, tmpdir):
    result.assert_success()

    checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
    result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-orphans.bst', '--directory', checkout])
    result.assert_success()
    assert os.path.exists(os.path.join(checkout, "baz"))

@@ -137,7 +138,7 @@ def test_filter_workspace_build(datafiles, cli, tmpdir):
    result = cli.run(project=project, args=['build', 'output-orphans.bst'])
    result.assert_success()
    checkout_dir = os.path.join(tempdir, "checkout")
    result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout_dir])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-orphans.bst', '--directory', checkout_dir])
    result.assert_success()
    assert os.path.exists(os.path.join(checkout_dir, "quux"))

@@ -157,7 +158,7 @@ def test_filter_workspace_close(datafiles, cli, tmpdir):
    result = cli.run(project=project, args=['build', 'output-orphans.bst'])
    result.assert_success()
    checkout_dir = os.path.join(tempdir, "checkout")
    result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout_dir])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-orphans.bst', '--directory', checkout_dir])
    result.assert_success()
    assert not os.path.exists(os.path.join(checkout_dir, "quux"))

@@ -177,7 +178,7 @@ def test_filter_workspace_reset(datafiles, cli, tmpdir):
    result = cli.run(project=project, args=['build', 'output-orphans.bst'])
    result.assert_success()
    checkout_dir = os.path.join(tempdir, "checkout")
    result = cli.run(project=project, args=['checkout', 'output-orphans.bst', checkout_dir])
    result = cli.run(project=project, args=['artifact', 'checkout', 'output-orphans.bst', '--directory', checkout_dir])
    result.assert_success()
    assert not os.path.exists(os.path.join(checkout_dir, "quux"))

+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ def test_autotools_build(cli, tmpdir, datafiles):
    result = cli.run(project=project, args=['build', 'hello.bst'])
    result.assert_success()

    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
    result = cli.run(project=project, args=['artifact', 'checkout', 'hello.bst', '--directory', checkout])
    result.assert_success()

    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
Loading