Skip to content

Commit

Permalink
rename checkout to develop (#163)
Browse files Browse the repository at this point in the history
(cherry picked from commit e2d6709c7c2d58383be10c14d51a3d954eb9e016)
  • Loading branch information
KristofferC committed Mar 6, 2018
1 parent d3d2d4e commit 3e50a74
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
21 changes: 12 additions & 9 deletions stdlib/Pkg3/src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,25 @@ function free(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
end


checkout(pkg::Union{String, PackageSpec}; kwargs...) = checkout([pkg]; kwargs...)
checkout(pkg::String, branch::String; kwargs...) = checkout([(PackageSpec(pkg), branch)]; kwargs...)
checkout(pkg::PackageSpec, branch::String; kwargs...) = checkout([(pkg, branch)]; kwargs...)
checkout(pkgs::Vector{String}; kwargs...) = checkout([(PackageSpec(pkg), nothing) for pkg in pkgs]; kwargs...)
checkout(pkgs::Vector{PackageSpec}; kwargs...) = checkout([(pkg, nothing) for pkg in pkgs]; kwargs...)
checkout(pkgs_branches::Vector; kwargs...) = checkout(Context(), pkgs_branches; kwargs...)

function checkout(ctx::Context, pkgs_branches::Vector; path = devdir(), kwargs...)
#deprecated
@deprecate checkout develop

develop(pkg::Union{String, PackageSpec}; kwargs...) = develop([pkg]; kwargs...)
develop(pkg::String, branch::String; kwargs...) = develop([(PackageSpec(pkg), branch)]; kwargs...)
develop(pkg::PackageSpec, branch::String; kwargs...) = develop([(pkg, branch)]; kwargs...)
develop(pkgs::Vector{String}; kwargs...) = develop([(PackageSpec(pkg), nothing) for pkg in pkgs]; kwargs...)
develop(pkgs::Vector{PackageSpec}; kwargs...) = develop([(pkg, nothing) for pkg in pkgs]; kwargs...)
develop(pkgs_branches::Vector; kwargs...) = develop(Context(), pkgs_branches; kwargs...)

function develop(ctx::Context, pkgs_branches::Vector; path = devdir(), kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
pkgs = [p[1] for p in pkgs_branches]
project_resolve!(ctx.env, pkgs)
registry_resolve!(ctx.env, pkgs)
ensure_resolved(ctx.env, pkgs)
Pkg3.Operations.checkout(ctx, pkgs_branches; path = path)
Pkg3.Operations.develop(ctx, pkgs_branches; path = path)
end


Expand Down
10 changes: 5 additions & 5 deletions stdlib/Pkg3/src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function collect_fixed!(ctx::Context, pkgs::Vector{PackageSpec}, uuid_to_name::D
info = manifest_info(ctx.env, pkg.uuid)
if pkg.special_action == PKGSPEC_FREED
continue
elseif pkg.special_action == PKGSPEC_CHECKED_OUT
elseif pkg.special_action == PKGSPEC_DEVELOPED
@assert pkg.path != nothing
elseif info !== nothing && get(info, "path", false) != false
pkg.path = info["path"]
Expand Down Expand Up @@ -895,13 +895,13 @@ function free(ctx::Context, pkgs::Vector{PackageSpec})
need_to_resolve && build_versions(ctx, new)
end

function checkout(ctx::Context, pkgs_branches::Vector; path = devdir())
function develop(ctx::Context, pkgs_branches::Vector; path = devdir())
pkgs = PackageSpec[]
for (pkg, branch) in pkgs_branches
push!(pkgs, pkg)
ctx.env.project["deps"][pkg.name] = string(pkg.uuid)
pkg.special_action = PKGSPEC_CHECKED_OUT
@info "Checking out $(pkg.name) [$(string(pkg.uuid)[1:8])]"
pkg.special_action = PKGSPEC_DEVELOPED
@info "Making $(pkg.name) [$(string(pkg.uuid)[1:8])] available for development..."

pkgpath = joinpath(path, pkg.name)
pkg.path = pkgpath
Expand All @@ -928,7 +928,7 @@ function checkout(ctx::Context, pkgs_branches::Vector; path = devdir())
end
end
if !successfully_cloned
cmderror("Failed to checkout $(pkg.name) [$(string(pkg.uuid)[1:8])] to $(pkgpath)")
cmderror("Failed to clone $(pkg.name) [$(string(pkg.uuid)[1:8])] to $(pkgpath)")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Pkg3/src/Pkg3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ include("Operations.jl")
include("REPLMode.jl")
include("API.jl")

import .API: add, rm, up, test, gc, init, build, installed, pin, free, checkout
import .API: add, rm, up, test, gc, init, build, installed, pin, free, checkout, develop
const update = up

function __init__()
Expand Down
30 changes: 19 additions & 11 deletions stdlib/Pkg3/src/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using Pkg3.Operations
############
@enum(CommandKind, CMD_HELP, CMD_STATUS, CMD_SEARCH, CMD_ADD, CMD_RM, CMD_UP,
CMD_TEST, CMD_GC, CMD_PREVIEW, CMD_INIT, CMD_BUILD, CMD_FREE,
CMD_PIN, CMD_CHECKOUT)
CMD_PIN, CMD_CHECKOUT, CMD_DEVELOP)

struct Command
kind::CommandKind
Expand Down Expand Up @@ -51,7 +51,9 @@ const cmds = Dict(
"build" => CMD_BUILD,
"pin" => CMD_PIN,
"free" => CMD_FREE,
"checkout" => CMD_CHECKOUT,
"checkout" => CMD_CHECKOUT, # deprecated
"develop" => CMD_DEVELOP,
"dev" => CMD_DEVELOP,
)

###########
Expand Down Expand Up @@ -245,6 +247,7 @@ function do_cmd!(tokens::Vector{Token}, repl)
cmd.kind == CMD_PIN ? Base.invokelatest( do_pin!, ctx, tokens) :
cmd.kind == CMD_FREE ? Base.invokelatest( do_free!, ctx, tokens) :
cmd.kind == CMD_CHECKOUT ? Base.invokelatest(do_checkout!, ctx, tokens) :
cmd.kind == CMD_DEVELOP ? Base.invokelatest(do_develop!, ctx, tokens) :
cmderror("`$cmd` command not yet implemented")
return
end
Expand Down Expand Up @@ -289,9 +292,9 @@ What action you want the package manager to take:
`pin`: pins the version of packages
`checkout`: clone the full package repo locally for development
`develop`: clone the full package repo locally for development
`free`: undos a `pin` or `checkout`
`free`: undos a `pin` or `develop`
"""

const helps = Dict(
Expand All @@ -305,7 +308,7 @@ const helps = Dict(
Display usage information for commands listed.
Available commands: `help`, `status`, `add`, `rm`, `up`, `preview`, `gc`, `test`, `init`, `build`, `free`, `pin`, `checkout`.
Available commands: `help`, `status`, `add`, `rm`, `up`, `preview`, `gc`, `test`, `init`, `build`, `free`, `pin`, `develop`.
""", CMD_STATUS => md"""
status
Expand Down Expand Up @@ -401,10 +404,10 @@ const helps = Dict(
""", CMD_FREE => md"""
free pkg[=uuid] ...
Free a pinned package `pkg`, which allows it to be upgraded or downgraded again. If the package is checked out (see `help checkout`) then this command
Free a pinned package `pkg`, which allows it to be upgraded or downgraded again. If the package is checked out (see `help develop`) then this command
makes the package no longer being checked out.
""", CMD_CHECKOUT => md"""
checkout pkg[=uuid] ...
""", CMD_DEVELOP => md"""
develop pkg[=uuid] ...
opts: --path | --branch
Expand All @@ -415,7 +418,7 @@ const helps = Dict(
*Example*
```jl
pkg> checkout --path=~/mydevpackages Example --branch=devel ACME --branch=feature/branch
pkg> develop --path=~/mydevpackages Example --branch=devel ACME --branch=feature/branch
```
"""
)
Expand Down Expand Up @@ -567,6 +570,11 @@ function do_free!(ctx::Context, tokens::Vector{Token})
end

function do_checkout!(ctx::Context, tokens::Vector{Token})
Base.depwarn("`checkout`` is deprecated, use `develop`", :checkout)
do_develop!(ctx, tokens)
end

function do_develop!(ctx::Context, tokens::Vector{Token})
pkgs_branches = Tuple{PackageSpec, Union{String, Nothing}}[] # (package, branch?)
path = devdir()
prev_token_was_package = false
Expand All @@ -582,14 +590,14 @@ function do_checkout!(ctx::Context, tokens::Vector{Token})
elseif token.kind == OPT_BRANCH
pkgs_branches[end] = (pkgs_branches[end][1], token.argument)
else
cmderror("invalid option for `checkout`: $token")
cmderror("invalid option for `develop`: $token")
end
else
cmderror("unexpected token $token")
end
prev_token_was_package = parsed_package
end
Pkg3.API.checkout(ctx, pkgs_branches; path = path)
Pkg3.API.develop(ctx, pkgs_branches; path = path)
end

function do_status!(ctx::Context, tokens::Vector{Token})
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Pkg3/src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export UUID, pkgID, SHA1, VersionRange, VersionSpec, empty_versionspec,
read_project, read_manifest, pathrepr, registries,
PackageMode, PKGMODE_MANIFEST, PKGMODE_PROJECT, PKGMODE_COMBINED,
UpgradeLevel, UPLEVEL_FIXED, UPLEVEL_PATCH, UPLEVEL_MINOR, UPLEVEL_MAJOR,
PackageSpecialAction, PKGSPEC_NOTHING, PKGSPEC_PINNED, PKGSPEC_FREED, PKGSPEC_CHECKED_OUT, PKGSPEC_TESTED
PackageSpecialAction, PKGSPEC_NOTHING, PKGSPEC_PINNED, PKGSPEC_FREED, PKGSPEC_DEVELOPED, PKGSPEC_TESTED


## ordering of UUIDs ##
Expand Down Expand Up @@ -376,7 +376,7 @@ function UpgradeLevel(s::Symbol)
end

@enum(PackageMode, PKGMODE_PROJECT, PKGMODE_MANIFEST, PKGMODE_COMBINED)
@enum(PackageSpecialAction, PKGSPEC_NOTHING, PKGSPEC_PINNED, PKGSPEC_FREED, PKGSPEC_CHECKED_OUT, PKGSPEC_TESTED)
@enum(PackageSpecialAction, PKGSPEC_NOTHING, PKGSPEC_PINNED, PKGSPEC_FREED, PKGSPEC_DEVELOPED, PKGSPEC_TESTED)

const VersionTypes = Union{VersionNumber,VersionSpec,UpgradeLevel}

Expand Down
6 changes: 3 additions & 3 deletions stdlib/Pkg3/test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ temp_pkg_dir() do project_path
Pkg3.rm(TEST_PKG.name)
end

@testset "checking out / freeing" begin
@testset "develop / freeing" begin
Pkg3.add(TEST_PKG.name)
old_v = Pkg3.installed()[TEST_PKG.name]
Pkg3.rm(TEST_PKG.name)
mktempdir() do devdir
Pkg3.checkout(TEST_PKG.name; path = devdir)
Pkg3.develop(TEST_PKG.name; path = devdir)
@test isinstalled(TEST_PKG)
@test Pkg3.installed()[TEST_PKG.name] > old_v
test_pkg_main_file = joinpath(devdir, TEST_PKG.name, "src", TEST_PKG.name * ".jl")
Expand Down Expand Up @@ -138,7 +138,7 @@ temp_pkg_dir() do project_path
end
mktempdir() do tmp
withenv("JULIA_PKG_DEVDIR" => tmp) do
@test_throws CommandError Pkg3.checkout(TEST_PKG.name, "nonexisting_branch",)
@test_throws CommandError Pkg3.develop(TEST_PKG.name, "nonexisting_branch",)
end
end
end
Expand Down

0 comments on commit 3e50a74

Please sign in to comment.