From f527a96eef785a11266b6bbf96828ab6582e8b49 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 30 Dec 2021 21:26:41 -0500 Subject: [PATCH 01/19] add updatable icons to status prints --- src/Operations.jl | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index 4c6dcb085e..a7f25dcb94 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1715,8 +1715,8 @@ end # Display -function stat_rep(x::PackageSpec; name=true) - name = name ? "$(x.name)" : "" +function stat_rep(x::PackageSpec; name=true, pad_length=0) + name = name ? "$(rpad(x.name, pad_length))" : "" version = x.version == VersionSpec() ? "" : "v$(x.version)" rev = "" if x.repo.rev !== nothing @@ -1729,25 +1729,25 @@ function stat_rep(x::PackageSpec; name=true) return join(filter(!isempty, [name,version,repo,path,pinned]), " ") end -print_single(io::IO, pkg::PackageSpec) = print(io, stat_rep(pkg)) +print_single(io::IO, pkg::PackageSpec, pad_length::Int) = print(io, stat_rep(pkg; pad_length)) is_instantiated(::Nothing) = false is_instantiated(x::PackageSpec) = x.version != VersionSpec() || is_stdlib(x.uuid) # Compare an old and new node of the dependency graph and print a single line to summarize the change -function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec}) +function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec}, pad_length::Int) if !is_instantiated(old) && is_instantiated(new) - printstyled(io, "+ $(stat_rep(new))"; color=:light_green) + printstyled(io, "+ $(stat_rep(new; pad_length))"; color=:light_green) elseif !is_instantiated(new) - printstyled(io, "- $(stat_rep(old))"; color=:light_red) + printstyled(io, "- $(stat_rep(old; pad_length))"; color=:light_red) elseif is_tracking_registry(old) && is_tracking_registry(new) && new.version isa VersionNumber && old.version isa VersionNumber && new.version != old.version if new.version > old.version - printstyled(io, "↑ $(stat_rep(old)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) + printstyled(io, "↑ $(stat_rep(old; pad_length)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) else - printstyled(io, "↓ $(stat_rep(old)) ⇒ $(stat_rep(new; name=false))"; color=:light_magenta) + printstyled(io, "↓ $(stat_rep(old; pad_length)) ⇒ $(stat_rep(new; name=false))"; color=:light_magenta) end else - printstyled(io, "~ $(stat_rep(old)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) + printstyled(io, "~ $(stat_rep(old; pad_length)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) end end @@ -1888,22 +1888,21 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie xs = sort!(xs, by = (x -> (is_stdlib(x[1]), endswith(something(x[3], x[2]).name, "_jll"), something(x[3], x[2]).name, x[1]))) all_packages_downloaded = true + longest_name_length = 0 package_statuses = PackageStatusData[] for (uuid, old, new) in xs if Types.is_project_uuid(env, uuid) continue end - + longest_name_length = max(length(something(old, new).name), longest_name_length) latest_version = true # Outdated info cinfo = nothing - if outdated - if diff == false && !is_stdlib(new.uuid) - @assert old == nothing - cinfo = status_compat_info(new, env, registries) - if cinfo !== nothing - latest_version = false - end + if diff == false && !is_stdlib(new.uuid) + @assert old == nothing + cinfo = status_compat_info(new, env, registries) + if cinfo !== nothing + latest_version = false end end # if we are running with outdated, only show packages that are upper bounded @@ -1921,7 +1920,12 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie latest_version = pkg.compat_data === nothing print(io, pkg.downloaded ? " " : not_installed_indicator) printstyled(io, " [", string(pkg.uuid)[1:8], "] "; color = :light_black) - diff ? print_diff(io, pkg.old, pkg.new) : print_single(io, pkg.new) + diff ? print_diff(io, pkg.old, pkg.new, longest_name_length) : print_single(io, pkg.new, longest_name_length) + + if !latest_version && !diff + packages_holding_back, _ = pkg.compat_data + print(io, isempty(packages_holding_back) ? " ⌃" : " ⌅") + end if outdated && !diff && pkg.compat_data !== nothing packages_holding_back, max_version, max_version_compat = pkg.compat_data if pkg.new.version !== max_version_compat && max_version_compat != max_version From 68d3873b70f267c179ad54366d779f8d91015ff3 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 31 Dec 2021 02:02:39 -0500 Subject: [PATCH 02/19] fix name length calc --- src/Operations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index a7f25dcb94..054dfb9630 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1894,7 +1894,6 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if Types.is_project_uuid(env, uuid) continue end - longest_name_length = max(length(something(old, new).name), longest_name_length) latest_version = true # Outdated info cinfo = nothing @@ -1909,6 +1908,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if outdated && latest_version continue end + longest_name_length = max(length(something(old, new).name), longest_name_length) pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.project_file, new) From ef83be5028ac797e1dbb7176919c345acf9e14de Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 31 Dec 2021 11:50:13 -0500 Subject: [PATCH 03/19] =?UTF-8?q?add=20=E2=8C=85=20hint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Operations.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index 054dfb9630..332aed2aea 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1915,7 +1915,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie all_packages_downloaded &= pkg_downloaded push!(package_statuses, PackageStatusData(uuid, old, new, pkg_downloaded, cinfo)) end - + no_packages_held_back = true for pkg in package_statuses latest_version = pkg.compat_data === nothing print(io, pkg.downloaded ? " " : not_installed_indicator) @@ -1924,7 +1924,12 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if !latest_version && !diff packages_holding_back, _ = pkg.compat_data - print(io, isempty(packages_holding_back) ? " ⌃" : " ⌅") + if isempty(packages_holding_back) + print(io, " ⌃") + else + no_packages_held_back = false + print(io, " ⌅") + end end if outdated && !diff && pkg.compat_data !== nothing packages_holding_back, max_version, max_version_compat = pkg.compat_data @@ -1946,6 +1951,9 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if !all_packages_downloaded printpkgstyle(io, :Info, "packages marked with $not_installed_indicator not downloaded, use `instantiate` to download", ignore_indent) end + if !no_packages_held_back + printpkgstyle(io, :Info, "packages marked with ⌅ have new versions available that cannot be installed. To see why use `status --outdated`", ignore_indent) + end return nothing end From 6669d1797ea686d38bd019b7ae674a7376bb87d0 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 31 Dec 2021 12:04:01 -0500 Subject: [PATCH 04/19] exclude repo- and path-tracking packages --- src/Operations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index 332aed2aea..81282b3605 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1922,7 +1922,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie printstyled(io, " [", string(pkg.uuid)[1:8], "] "; color = :light_black) diff ? print_diff(io, pkg.old, pkg.new, longest_name_length) : print_single(io, pkg.new, longest_name_length) - if !latest_version && !diff + if !latest_version && !diff && !Operations.is_tracking_repo(pkg.new) && !Operations.is_tracking_path(pkg.new) packages_holding_back, _ = pkg.compat_data if isempty(packages_holding_back) print(io, " ⌃") From bee56b16c32be3f284c66e7859a4bcd65d6bd551 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 31 Dec 2021 12:15:36 -0500 Subject: [PATCH 05/19] adjust status print test patterns --- test/new.jl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test/new.jl b/test/new.jl index 226e8590bc..d678ab345a 100644 --- a/test/new.jl +++ b/test/new.jl @@ -290,7 +290,7 @@ end @test_skip Pkg.test("Permutations") else Pkg.test("Permutations") - end + end end end @@ -2101,9 +2101,9 @@ end Pkg.add(url="https://github.com/00vareladavid/Unregistered.jl") Pkg.status(; io = io) @test occursin(r"Status `.+Project\.toml`", readline(io)) - @test occursin(r"\[7876af07\] Example v\d\.\d\.\d `.+`", readline(io)) - @test occursin(r"\[682c06a0\] JSON v0.18.0", readline(io)) - @test occursin(r"\[dcb67f36\] Unregistered v\d\.\d\.\d `https://github\.com/00vareladavid/Unregistered\.jl#master`", readline(io)) + @test occursin(r"\[7876af07\] Example\s*v\d\.\d\.\d\s*`.+`", readline(io)) + @test occursin(r"\[682c06a0\] JSON\s*v0.18.0", readline(io)) + @test occursin(r"\[dcb67f36\] Unregistered\s*v\d\.\d\.\d\s*`https://github\.com/00vareladavid/Unregistered\.jl#master`", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) end ## status warns when package not installed @@ -2113,15 +2113,17 @@ end io = PipeBuffer() Pkg.status(; io=io) @test occursin(r"Status `.+Project.toml`", readline(io)) - @test occursin(r"→ \[7876af07\] Example v\d\.\d\.\d", readline(io)) + @test occursin(r"→ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) @test "Info packages marked with → not downloaded, use `instantiate` to download" == strip(readline(io)) + @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) Pkg.status(;io=io, mode=Pkg.PKGMODE_MANIFEST) @test occursin(r"Status `.+Manifest.toml`", readline(io)) - @test occursin(r"→ \[7876af07\] Example v\d\.\d\.\d", readline(io)) + @test occursin(r"→ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[2a0f44e3\] Base64", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) @test "Info packages marked with → not downloaded, use `instantiate` to download" == strip(readline(io)) + @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) end # Manifest Status API isolate(loaded_depot=true) do @@ -2135,7 +2137,7 @@ end Pkg.add("Markdown") Pkg.status(; io=io, mode=Pkg.PKGMODE_MANIFEST) @test occursin(r"Status `.+Manifest.toml`", readline(io)) - @test occursin(r"\[7876af07\] Example v0\.3\.0", readline(io)) + @test occursin(r"\[7876af07\] Example\s*v0\.3\.0", readline(io)) @test occursin(r"\[2a0f44e3\] Base64", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) end @@ -2170,12 +2172,12 @@ end ## diff project Pkg.status(; io=io, diff=true) @test occursin(r"Diff `.+Project\.toml`", readline(io)) - @test occursin(r"\[7876af07\] \+ Example v0\.3\.0", readline(io)) + @test occursin(r"\[7876af07\] \+ Example\s*v0\.3\.0", readline(io)) @test occursin(r"\[d6f4376e\] - Markdown", readline(io)) ## diff manifest Pkg.status(; io=io, mode=Pkg.PKGMODE_MANIFEST, diff=true) @test occursin(r"Diff `.+Manifest.toml`", readline(io)) - @test occursin(r"\[7876af07\] \+ Example v0\.3\.0", readline(io)) + @test occursin(r"\[7876af07\] \+ Example\s*v0\.3\.0", readline(io)) @test occursin(r"\[2a0f44e3\] - Base64", readline(io)) @test occursin(r"\[d6f4376e\] - Markdown", readline(io)) ## diff project with filtering @@ -2202,7 +2204,7 @@ end Pkg.add(Pkg.PackageSpec(name="Example", version="0.4.0"); io=devnull) Pkg.status(; outdated=true, io=io) str = String(take!(io)) - @test occursin("[7876af07] Example v0.4.0 ( Date: Fri, 31 Dec 2021 16:35:38 -0500 Subject: [PATCH 06/19] =?UTF-8?q?add=20=E2=8C=83=20hint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Operations.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index 81282b3605..ba831db319 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1915,6 +1915,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie all_packages_downloaded &= pkg_downloaded push!(package_statuses, PackageStatusData(uuid, old, new, pkg_downloaded, cinfo)) end + no_packages_upgradable = true no_packages_held_back = true for pkg in package_statuses latest_version = pkg.compat_data === nothing @@ -1925,6 +1926,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if !latest_version && !diff && !Operations.is_tracking_repo(pkg.new) && !Operations.is_tracking_path(pkg.new) packages_holding_back, _ = pkg.compat_data if isempty(packages_holding_back) + no_packages_upgradable = false print(io, " ⌃") else no_packages_held_back = false @@ -1951,8 +1953,14 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if !all_packages_downloaded printpkgstyle(io, :Info, "packages marked with $not_installed_indicator not downloaded, use `instantiate` to download", ignore_indent) end - if !no_packages_held_back - printpkgstyle(io, :Info, "packages marked with ⌅ have new versions available that cannot be installed. To see why use `status --outdated`", ignore_indent) + if !no_packages_upgradable && no_packages_held_back + printpkgstyle(io, :Info, "packages marked with ⌃ have new versions available", ignore_indent) + end + if !no_packages_held_back && no_packages_upgradable + printpkgstyle(io, :Info, "packages marked with ⌅ have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + end + if !no_packages_held_back && !no_packages_upgradable + printpkgstyle(io, :Info, "packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) end return nothing From e440b8e2dc117698ba542457a34a35aa512c507b Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 31 Dec 2021 19:29:35 -0500 Subject: [PATCH 07/19] also align cols beyond version --- src/Operations.jl | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index ba831db319..98774627bb 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1715,9 +1715,9 @@ end # Display -function stat_rep(x::PackageSpec; name=true, pad_length=0) - name = name ? "$(rpad(x.name, pad_length))" : "" - version = x.version == VersionSpec() ? "" : "v$(x.version)" +function stat_rep(x::PackageSpec; name=true, pad_name=0, pad_version=0) + name = name ? "$(rpad(x.name, pad_name))" : "" + version = rpad(x.version == VersionSpec() ? "" : "v$(x.version)", pad_version) rev = "" if x.repo.rev !== nothing rev = occursin(r"\b([a-f0-9]{40})\b", x.repo.rev) ? x.repo.rev[1:7] : x.repo.rev @@ -1729,25 +1729,25 @@ function stat_rep(x::PackageSpec; name=true, pad_length=0) return join(filter(!isempty, [name,version,repo,path,pinned]), " ") end -print_single(io::IO, pkg::PackageSpec, pad_length::Int) = print(io, stat_rep(pkg; pad_length)) +print_single(io::IO, pkg::PackageSpec, pad_name::Int, pad_version::Int) = print(io, stat_rep(pkg; pad_name, pad_version)) is_instantiated(::Nothing) = false is_instantiated(x::PackageSpec) = x.version != VersionSpec() || is_stdlib(x.uuid) # Compare an old and new node of the dependency graph and print a single line to summarize the change -function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec}, pad_length::Int) +function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec}, pad_name::Int, pad_version::Int) if !is_instantiated(old) && is_instantiated(new) - printstyled(io, "+ $(stat_rep(new; pad_length))"; color=:light_green) + printstyled(io, "+ $(stat_rep(new; pad_name, pad_version))"; color=:light_green) elseif !is_instantiated(new) - printstyled(io, "- $(stat_rep(old; pad_length))"; color=:light_red) + printstyled(io, "- $(stat_rep(old; pad_name, pad_version))"; color=:light_red) elseif is_tracking_registry(old) && is_tracking_registry(new) && new.version isa VersionNumber && old.version isa VersionNumber && new.version != old.version if new.version > old.version - printstyled(io, "↑ $(stat_rep(old; pad_length)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) + printstyled(io, "↑ $(stat_rep(old; pad_name, pad_version)) ⇒ $(stat_rep(new; name=false, pad_version))"; color=:light_yellow) else - printstyled(io, "↓ $(stat_rep(old; pad_length)) ⇒ $(stat_rep(new; name=false))"; color=:light_magenta) + printstyled(io, "↓ $(stat_rep(old; pad_name, pad_version)) ⇒ $(stat_rep(new; name=false, pad_version))"; color=:light_magenta) end else - printstyled(io, "~ $(stat_rep(old; pad_length)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) + printstyled(io, "~ $(stat_rep(old; pad_name, pad_version)) ⇒ $(stat_rep(new; name=false, pad_version))"; color=:light_yellow) end end @@ -1889,6 +1889,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie all_packages_downloaded = true longest_name_length = 0 + longest_version_length = 0 package_statuses = PackageStatusData[] for (uuid, old, new) in xs if Types.is_project_uuid(env, uuid) @@ -1909,6 +1910,9 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie continue end longest_name_length = max(length(something(old, new).name), longest_name_length) + v = something(old, new).version + v_str = v == VersionSpec() ? "" : "v$(v)" + longest_version_length = max(length(v_str), longest_version_length) pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.project_file, new) @@ -1921,7 +1925,11 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie latest_version = pkg.compat_data === nothing print(io, pkg.downloaded ? " " : not_installed_indicator) printstyled(io, " [", string(pkg.uuid)[1:8], "] "; color = :light_black) - diff ? print_diff(io, pkg.old, pkg.new, longest_name_length) : print_single(io, pkg.new, longest_name_length) + if diff + print_diff(io, pkg.old, pkg.new, longest_name_length, longest_version_length) + else + print_single(io, pkg.new, longest_name_length, longest_version_length) + end if !latest_version && !diff && !Operations.is_tracking_repo(pkg.new) && !Operations.is_tracking_path(pkg.new) packages_holding_back, _ = pkg.compat_data From 74a2bc5a5cb5898e69b25116c6f2fd0d2ab6866b Mon Sep 17 00:00:00 2001 From: Ian Date: Sat, 1 Jan 2022 15:01:29 -0500 Subject: [PATCH 08/19] add to docs and changelog --- CHANGELOG.md | 2 ++ src/Pkg.jl | 24 +++++++++++++++--------- src/REPLMode/command_declarations.jl | 14 +++++++++----- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d044a683d5..c8e5607f00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ Pkg v1.8 Release Notes ====================== +- New `⌃` and `⌅` indicators beside packages in `pkg> status` that have new versions available. + `⌅` indicates when new versions cannot be installed. - New `outdated::Bool` kwarg to `Pkg.status` (`--outdated` or `-o` in the REPL mode) to show information about packages not at the latest version. - New `compat::Bool` kwarg to `Pkg.status` (`--compat` or `-c` in the REPL mode) to show any [compat] diff --git a/src/Pkg.jl b/src/Pkg.jl index b538e5948f..d70b04b232 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -394,13 +394,9 @@ const resolve = API.resolve Pkg.status([pkgs...]; mode::PackageMode=PKGMODE_PROJECT, diff::Bool=false, compat::Bool=false, io::IO=stdout) Print out the status of the project/manifest. -If `mode` is `PKGMODE_PROJECT`, print out status only about the packages -that are in the project (explicitly added). If `mode` is `PKGMODE_MANIFEST`, -print status also about those in the manifest (recursive dependencies). If there are -any packages listed as arguments, the output will be limited to those packages. -Setting `diff=true` will, if the environment is in a git repository, limit -the output to the difference as compared to the last git commit. +Packages marked with `⌃` have new versions that can be installed, e.g. via [`Pkg.up`](@ref). +Those marked with `⌅` have new versions available, but that cannot be installed. To see why use the `outdated` kwarg. Setting `outdated=true` will only show packages that are not on the latest version, their maximum version and why they are not on the latest version (either due to other @@ -409,9 +405,9 @@ As an example, a status output like: ``` pkg> Pkg.status(; outdated=true) Status `Manifest.toml` - [a8cc5b0e] Crayons v2.0.0 [ "status", [st|status] [-d|--diff] [-o|--outdated] [-m|--manifest] [pkgs...] [st|status] [-c|--compat] [pkgs...] -Show the status of the current environment. In `--project` mode (default), the -status of the project file is summarized. In `--manifest` mode the output also -includes the recursive dependencies of added packages given in the manifest. +Show the status of the current environment. +Packages marked with `⌃` have new versions that can be installed, e.g. via `pkg> up`. +Those marked with `⌅` have new versions available, but that cannot be installed. To see why +use `pkg> status --outdated` which shows any packages that are not at their latest version +and if any packages are holding them back. + +In `--project` mode (default), the status of the project file is summarized. In `--manifest` +mode the output also includes the recursive dependencies of added packages given in the manifest. If there are any packages listed as arguments the output will be limited to those packages. The `--diff` option will, if the environment is in a git repository, limit the output to the difference as compared to the last git commit. -The `--outdated` option in addition show if some packages are not at their latest version -and what packages are holding them back. The `--compat` option alone shows project compat entries. !!! compat "Julia 1.1" @@ -382,6 +385,7 @@ The `--compat` option alone shows project compat entries. is the default for environments in git repositories. !!! compat "Julia 1.8" + The `⌃` and `⌅` indicators were added in Julia 1.8 The `--outdated` and `--compat` options require at least Julia 1.8. """, ], From dd79a762c35d5684420089409fc5e4053bca8115 Mon Sep 17 00:00:00 2001 From: Ian Date: Sat, 1 Jan 2022 15:33:31 -0500 Subject: [PATCH 09/19] more formatting & padding fixes --- src/Operations.jl | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index 98774627bb..96d8580813 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1715,9 +1715,16 @@ end # Display -function stat_rep(x::PackageSpec; name=true, pad_name=0, pad_version=0) +function stat_rep(x::PackageSpec; name=true, pad_name=0, pad_version=0, upgradable=false, heldback=false) name = name ? "$(rpad(x.name, pad_name))" : "" - version = rpad(x.version == VersionSpec() ? "" : "v$(x.version)", pad_version) + version = x.version == VersionSpec() ? "" : "v$(x.version)" + if upgradable + version = string(version, " ⌃") + end + if heldback + version = string(version, " ⌅") + end + version = rpad(version, pad_version) rev = "" if x.repo.rev !== nothing rev = occursin(r"\b([a-f0-9]{40})\b", x.repo.rev) ? x.repo.rev[1:7] : x.repo.rev @@ -1729,7 +1736,9 @@ function stat_rep(x::PackageSpec; name=true, pad_name=0, pad_version=0) return join(filter(!isempty, [name,version,repo,path,pinned]), " ") end -print_single(io::IO, pkg::PackageSpec, pad_name::Int, pad_version::Int) = print(io, stat_rep(pkg; pad_name, pad_version)) +function print_single(io::IO, pkg::PackageSpec, pad_name::Int, pad_version::Int, upgradable::Bool, heldback::Bool) + print(io, stat_rep(pkg; pad_name, pad_version, upgradable, heldback)) +end is_instantiated(::Nothing) = false is_instantiated(x::PackageSpec) = x.version != VersionSpec() || is_stdlib(x.uuid) @@ -1910,9 +1919,15 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie continue end longest_name_length = max(length(something(old, new).name), longest_name_length) + v = something(old, new).version v_str = v == VersionSpec() ? "" : "v$(v)" - longest_version_length = max(length(v_str), longest_version_length) + longest_version_length = if !latest_version && !diff && !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new) + # if an updatable indicator will be shown + max(length(v_str) + 2, longest_version_length) + else + max(length(v_str), longest_version_length) + end pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.project_file, new) @@ -1925,22 +1940,24 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie latest_version = pkg.compat_data === nothing print(io, pkg.downloaded ? " " : not_installed_indicator) printstyled(io, " [", string(pkg.uuid)[1:8], "] "; color = :light_black) - if diff - print_diff(io, pkg.old, pkg.new, longest_name_length, longest_version_length) - else - print_single(io, pkg.new, longest_name_length, longest_version_length) - end - + upgradable, heldback = false, false if !latest_version && !diff && !Operations.is_tracking_repo(pkg.new) && !Operations.is_tracking_path(pkg.new) packages_holding_back, _ = pkg.compat_data if isempty(packages_holding_back) + upgradable = true no_packages_upgradable = false - print(io, " ⌃") else + heldback = true no_packages_held_back = false - print(io, " ⌅") end end + + if diff + print_diff(io, pkg.old, pkg.new, longest_name_length, longest_version_length) + else + print_single(io, pkg.new, longest_name_length, longest_version_length, upgradable, heldback) + end + if outdated && !diff && pkg.compat_data !== nothing packages_holding_back, max_version, max_version_compat = pkg.compat_data if pkg.new.version !== max_version_compat && max_version_compat != max_version From 102b87b0d59b8dd650ede6fe2ddd0f139671f524 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 2 Jan 2022 15:46:59 -0500 Subject: [PATCH 10/19] move indicators to start, remove column formatting --- src/Operations.jl | 101 +++++++++++++++++++++------------------------- test/new.jl | 4 +- 2 files changed, 48 insertions(+), 57 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index 96d8580813..4fbe230ffc 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1715,16 +1715,9 @@ end # Display -function stat_rep(x::PackageSpec; name=true, pad_name=0, pad_version=0, upgradable=false, heldback=false) - name = name ? "$(rpad(x.name, pad_name))" : "" +function stat_rep(x::PackageSpec; name=true) + name = name ? "$(x.name)" : "" version = x.version == VersionSpec() ? "" : "v$(x.version)" - if upgradable - version = string(version, " ⌃") - end - if heldback - version = string(version, " ⌅") - end - version = rpad(version, pad_version) rev = "" if x.repo.rev !== nothing rev = occursin(r"\b([a-f0-9]{40})\b", x.repo.rev) ? x.repo.rev[1:7] : x.repo.rev @@ -1736,27 +1729,25 @@ function stat_rep(x::PackageSpec; name=true, pad_name=0, pad_version=0, upgradab return join(filter(!isempty, [name,version,repo,path,pinned]), " ") end -function print_single(io::IO, pkg::PackageSpec, pad_name::Int, pad_version::Int, upgradable::Bool, heldback::Bool) - print(io, stat_rep(pkg; pad_name, pad_version, upgradable, heldback)) -end +print_single(io::IO, pkg::PackageSpec) = print(io, stat_rep(pkg)) is_instantiated(::Nothing) = false is_instantiated(x::PackageSpec) = x.version != VersionSpec() || is_stdlib(x.uuid) # Compare an old and new node of the dependency graph and print a single line to summarize the change -function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec}, pad_name::Int, pad_version::Int) +function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec}) if !is_instantiated(old) && is_instantiated(new) - printstyled(io, "+ $(stat_rep(new; pad_name, pad_version))"; color=:light_green) + printstyled(io, "+ $(stat_rep(new))"; color=:light_green) elseif !is_instantiated(new) - printstyled(io, "- $(stat_rep(old; pad_name, pad_version))"; color=:light_red) + printstyled(io, "- $(stat_rep(old))"; color=:light_red) elseif is_tracking_registry(old) && is_tracking_registry(new) && new.version isa VersionNumber && old.version isa VersionNumber && new.version != old.version if new.version > old.version - printstyled(io, "↑ $(stat_rep(old; pad_name, pad_version)) ⇒ $(stat_rep(new; name=false, pad_version))"; color=:light_yellow) + printstyled(io, "↑ $(stat_rep(old)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) else - printstyled(io, "↓ $(stat_rep(old; pad_name, pad_version)) ⇒ $(stat_rep(new; name=false, pad_version))"; color=:light_magenta) + printstyled(io, "↓ $(stat_rep(old)) ⇒ $(stat_rep(new; name=false))"; color=:light_magenta) end else - printstyled(io, "~ $(stat_rep(old; pad_name, pad_version)) ⇒ $(stat_rep(new; name=false, pad_version))"; color=:light_yellow) + printstyled(io, "~ $(stat_rep(old)) ⇒ $(stat_rep(new; name=false))"; color=:light_yellow) end end @@ -1864,13 +1855,16 @@ struct PackageStatusData old::Union{Nothing, PackageSpec} new::Union{Nothing, PackageSpec} downloaded::Bool + upgradable::Bool + heldback::Bool compat_data::Union{Nothing, Tuple{Vector{String}, VersionNumber, VersionNumber}} end function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registries::Vector{Registry.RegistryInstance}, header::Symbol, uuids::Vector, names::Vector; manifest=true, diff=false, ignore_indent::Bool, outdated::Bool, io::IO) not_installed_indicator = sprint((io, args) -> printstyled(io, args...; color=:red), "→", context=io) - not_latest_version_indicator = sprint((io, args) -> printstyled(io, args...; color=:yellow), "↓", context=io) + upgradable_indicator = sprint((io, args) -> printstyled(io, args...; color=:green), "⌃", context=io) + heldback_indicator = sprint((io, args) -> printstyled(io, args...; color=:normal), "⌅", context=io) filter = !isempty(uuids) || !isempty(names) # setup xs = diff_array(old_env, env; manifest=manifest) @@ -1896,9 +1890,10 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie # Sort stdlibs and _jlls towards the end in status output xs = sort!(xs, by = (x -> (is_stdlib(x[1]), endswith(something(x[3], x[2]).name, "_jll"), something(x[3], x[2]).name, x[1]))) all_packages_downloaded = true + no_packages_upgradable = true + no_packages_held_back = true + lpadding = 2 - longest_name_length = 0 - longest_version_length = 0 package_statuses = PackageStatusData[] for (uuid, old, new) in xs if Types.is_project_uuid(env, uuid) @@ -1918,46 +1913,42 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie if outdated && latest_version continue end - longest_name_length = max(length(something(old, new).name), longest_name_length) - - v = something(old, new).version - v_str = v == VersionSpec() ? "" : "v$(v)" - longest_version_length = if !latest_version && !diff && !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new) - # if an updatable indicator will be shown - max(length(v_str) + 2, longest_version_length) - else - max(length(v_str), longest_version_length) - end pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.project_file, new) + new_ver_avail = !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new) && !latest_version + pkg_upgradable = new_ver_avail && isempty(cinfo[1]) + pkg_heldback = new_ver_avail && !isempty(cinfo[1]) + + if !pkg_downloaded && (pkg_upgradable || pkg_heldback) + # allow space in the gutter for two icons on a single line + lpadding = 3 + end + all_packages_downloaded &= pkg_downloaded - push!(package_statuses, PackageStatusData(uuid, old, new, pkg_downloaded, cinfo)) + no_packages_upgradable &= !pkg_upgradable + no_packages_held_back &= !pkg_heldback + push!(package_statuses, PackageStatusData(uuid, old, new, pkg_downloaded, pkg_upgradable, pkg_heldback, cinfo)) end - no_packages_upgradable = true - no_packages_held_back = true - for pkg in package_statuses - latest_version = pkg.compat_data === nothing - print(io, pkg.downloaded ? " " : not_installed_indicator) - printstyled(io, " [", string(pkg.uuid)[1:8], "] "; color = :light_black) - upgradable, heldback = false, false - if !latest_version && !diff && !Operations.is_tracking_repo(pkg.new) && !Operations.is_tracking_path(pkg.new) - packages_holding_back, _ = pkg.compat_data - if isempty(packages_holding_back) - upgradable = true - no_packages_upgradable = false - else - heldback = true - no_packages_held_back = false - end - end - if diff - print_diff(io, pkg.old, pkg.new, longest_name_length, longest_version_length) + for pkg in package_statuses + if !pkg.downloaded + print(io, not_installed_indicator) + elseif lpadding > 2 + print(io, " ") + end + if pkg.upgradable + print(io, upgradable_indicator) + elseif pkg.heldback + print(io, heldback_indicator) else - print_single(io, pkg.new, longest_name_length, longest_version_length, upgradable, heldback) + print(io, " ") end + printstyled(io, " [", string(pkg.uuid)[1:8], "] "; color = :light_black) + + diff ? print_diff(io, pkg.old, pkg.new) : print_single(io, pkg.new) + if outdated && !diff && pkg.compat_data !== nothing packages_holding_back, max_version, max_version_compat = pkg.compat_data if pkg.new.version !== max_version_compat && max_version_compat != max_version @@ -1979,13 +1970,13 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie printpkgstyle(io, :Info, "packages marked with $not_installed_indicator not downloaded, use `instantiate` to download", ignore_indent) end if !no_packages_upgradable && no_packages_held_back - printpkgstyle(io, :Info, "packages marked with ⌃ have new versions available", ignore_indent) + printpkgstyle(io, :Info, "packages marked with $upgradable_indicator have new versions available", ignore_indent) end if !no_packages_held_back && no_packages_upgradable - printpkgstyle(io, :Info, "packages marked with ⌅ have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + printpkgstyle(io, :Info, "packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) end if !no_packages_held_back && !no_packages_upgradable - printpkgstyle(io, :Info, "packages marked with ⌃ and ⌅ have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) + printpkgstyle(io, :Info, "packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) end return nothing diff --git a/test/new.jl b/test/new.jl index d678ab345a..09beea98f1 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2204,7 +2204,7 @@ end Pkg.add(Pkg.PackageSpec(name="Example", version="0.4.0"); io=devnull) Pkg.status(; outdated=true, io=io) str = String(take!(io)) - @test occursin(Regex("\\[7876af07\\] Example\\s*v0.4.0\\s*⌃\\s*\\( Date: Sun, 2 Jan 2022 15:47:11 -0500 Subject: [PATCH 11/19] grammar fix --- src/Operations.jl | 2 +- test/new.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index 4fbe230ffc..34d50d3f49 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1967,7 +1967,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie end if !all_packages_downloaded - printpkgstyle(io, :Info, "packages marked with $not_installed_indicator not downloaded, use `instantiate` to download", ignore_indent) + printpkgstyle(io, :Info, "packages marked with $not_installed_indicator are not downloaded, use `instantiate` to download", ignore_indent) end if !no_packages_upgradable && no_packages_held_back printpkgstyle(io, :Info, "packages marked with $upgradable_indicator have new versions available", ignore_indent) diff --git a/test/new.jl b/test/new.jl index 09beea98f1..9c02171089 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2115,14 +2115,14 @@ end @test occursin(r"Status `.+Project.toml`", readline(io)) @test occursin(r"→ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) - @test "Info packages marked with → not downloaded, use `instantiate` to download" == strip(readline(io)) + @test "Info packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) Pkg.status(;io=io, mode=Pkg.PKGMODE_MANIFEST) @test occursin(r"Status `.+Manifest.toml`", readline(io)) @test occursin(r"→ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[2a0f44e3\] Base64", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) - @test "Info packages marked with → not downloaded, use `instantiate` to download" == strip(readline(io)) + @test "Info packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) end # Manifest Status API From 55f8790029adbe99ff3e166893458ae69aec8328 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 2 Jan 2022 16:00:07 -0500 Subject: [PATCH 12/19] fix --- src/Operations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index 34d50d3f49..b29e15adde 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1916,7 +1916,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie pkg_downloaded = !is_instantiated(new) || is_package_downloaded(env.project_file, new) - new_ver_avail = !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new) && !latest_version + new_ver_avail = !latest_version && !Operations.is_tracking_repo(new) && !Operations.is_tracking_path(new) pkg_upgradable = new_ver_avail && isempty(cinfo[1]) pkg_heldback = new_ver_avail && !isempty(cinfo[1]) From 3d857c09f869b838b87e3b3c99f6a1abfc322443 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 2 Jan 2022 16:46:01 -0500 Subject: [PATCH 13/19] more fix --- test/new.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/new.jl b/test/new.jl index 9c02171089..1cfe32abfa 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2113,13 +2113,13 @@ end io = PipeBuffer() Pkg.status(; io=io) @test occursin(r"Status `.+Project.toml`", readline(io)) - @test occursin(r"→ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) + @test occursin(r"→⌃ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) @test "Info packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) Pkg.status(;io=io, mode=Pkg.PKGMODE_MANIFEST) @test occursin(r"Status `.+Manifest.toml`", readline(io)) - @test occursin(r"→ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) + @test occursin(r"→⌃ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[2a0f44e3\] Base64", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) @test "Info packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) From b8b1d45fa0701fbf929aa9949d099aa4495a23fd Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 2 Jan 2022 20:02:22 -0500 Subject: [PATCH 14/19] add info message to no-change diff too --- src/Operations.jl | 60 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index b29e15adde..b1628f4555 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1861,7 +1861,7 @@ struct PackageStatusData end function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registries::Vector{Registry.RegistryInstance}, header::Symbol, - uuids::Vector, names::Vector; manifest=true, diff=false, ignore_indent::Bool, outdated::Bool, io::IO) + uuids::Vector, names::Vector; manifest=true, diff=false, ignore_indent::Bool, outdated::Bool, io::IO, mode::PackageMode) not_installed_indicator = sprint((io, args) -> printstyled(io, args...; color=:red), "→", context=io) upgradable_indicator = sprint((io, args) -> printstyled(io, args...; color=:green), "⌃", context=io) heldback_indicator = sprint((io, args) -> printstyled(io, args...; color=:normal), "⌅", context=io) @@ -1874,21 +1874,22 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie (manifest ? "manifest" : "project") * ")", ignore_indent) return nothing end - xs = !diff ? xs : eltype(xs)[(id, old, new) for (id, old, new) in xs if old != new] - if isempty(xs) + no_changes = all(p-> p[2] == p[3], xs) + if no_changes printpkgstyle(io, Symbol("No Changes"), "to $(pathrepr(manifest ? env.manifest_file : env.project_file))", ignore_indent) - return nothing - end - xs = !filter ? xs : eltype(xs)[(id, old, new) for (id, old, new) in xs if (id in uuids || something(new, old).name in names)] - if isempty(xs) - printpkgstyle(io, Symbol("No Matches"), - "in $(diff ? "diff for " : "")$(pathrepr(manifest ? env.manifest_file : env.project_file))", ignore_indent) - return nothing + else + xs = !filter ? xs : eltype(xs)[(id, old, new) for (id, old, new) in xs if (id in uuids || something(new, old).name in names)] + if isempty(xs) + printpkgstyle(io, Symbol("No Matches"), + "in $(diff ? "diff for " : "")$(pathrepr(manifest ? env.manifest_file : env.project_file))", ignore_indent) + return nothing + end + # main print + printpkgstyle(io, header, pathrepr(manifest ? env.manifest_file : env.project_file), ignore_indent) + # Sort stdlibs and _jlls towards the end in status output + xs = sort!(xs, by = (x -> (is_stdlib(x[1]), endswith(something(x[3], x[2]).name, "_jll"), something(x[3], x[2]).name, x[1]))) end - # main print - printpkgstyle(io, header, pathrepr(manifest ? env.manifest_file : env.project_file), ignore_indent) - # Sort stdlibs and _jlls towards the end in status output - xs = sort!(xs, by = (x -> (is_stdlib(x[1]), endswith(something(x[3], x[2]).name, "_jll"), something(x[3], x[2]).name, x[1]))) + all_packages_downloaded = true no_packages_upgradable = true no_packages_held_back = true @@ -1902,8 +1903,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie latest_version = true # Outdated info cinfo = nothing - if diff == false && !is_stdlib(new.uuid) - @assert old == nothing + if !is_stdlib(new.uuid) cinfo = status_compat_info(new, env, registries) if cinfo !== nothing latest_version = false @@ -1932,6 +1932,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie end for pkg in package_statuses + pkg.old == pkg.new && continue # don't print packages that didn't change if !pkg.downloaded print(io, not_installed_indicator) elseif lpadding > 2 @@ -1966,17 +1967,22 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie println(io) end - if !all_packages_downloaded + if !no_changes && !all_packages_downloaded printpkgstyle(io, :Info, "packages marked with $not_installed_indicator are not downloaded, use `instantiate` to download", ignore_indent) end - if !no_packages_upgradable && no_packages_held_back - printpkgstyle(io, :Info, "packages marked with $upgradable_indicator have new versions available", ignore_indent) - end - if !no_packages_held_back && no_packages_upgradable - printpkgstyle(io, :Info, "packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) - end - if !no_packages_held_back && !no_packages_upgradable - printpkgstyle(io, :Info, "packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) + if !outdated && (mode != PKGMODE_COMBINED || (manifest == true)) + if !no_changes && !no_packages_upgradable && no_packages_held_back + printpkgstyle(io, :Info, "packages marked with $upgradable_indicator have new versions available", ignore_indent) + end + if !no_changes && !no_packages_held_back && no_packages_upgradable + printpkgstyle(io, :Info, "packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + end + if !no_changes && !no_packages_held_back && !no_packages_upgradable + printpkgstyle(io, :Info, "packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) + end + if no_changes && diff && !no_packages_held_back + printpkgstyle(io, :Info, "some packages have new versions but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + end end return nothing @@ -2036,10 +2042,10 @@ function status(env::EnvCache, registries::Vector{Registry.RegistryInstance}, pk diff = old_env !== nothing header = something(header, diff ? :Diff : :Status) if mode == PKGMODE_PROJECT || mode == PKGMODE_COMBINED - print_status(env, old_env, registries, header, filter_uuids, filter_names; manifest=false, diff, ignore_indent, io, outdated) + print_status(env, old_env, registries, header, filter_uuids, filter_names; manifest=false, diff, ignore_indent, io, outdated, mode) end if mode == PKGMODE_MANIFEST || mode == PKGMODE_COMBINED - print_status(env, old_env, registries, header, filter_uuids, filter_names; diff, ignore_indent, io, outdated) + print_status(env, old_env, registries, header, filter_uuids, filter_names; diff, ignore_indent, io, outdated, mode) end if is_manifest_current(env) === false printpkgstyle(io, :Warning, """The project dependencies or compat requirements have changed since the manifest was last resolved. \ From e697c9eeeb8f89d533b59905f03d98ff638a025d Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 2 Jan 2022 20:35:50 -0500 Subject: [PATCH 15/19] also add heldback info to no-change upgrade --- src/Operations.jl | 37 ++++++++++++++++++++----------------- test/new.jl | 10 ++++++---- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index b1628f4555..fc5eaa0bd5 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1858,6 +1858,7 @@ struct PackageStatusData upgradable::Bool heldback::Bool compat_data::Union{Nothing, Tuple{Vector{String}, VersionNumber, VersionNumber}} + changed::Bool end function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registries::Vector{Registry.RegistryInstance}, header::Symbol, @@ -1892,7 +1893,8 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie all_packages_downloaded = true no_packages_upgradable = true - no_packages_held_back = true + no_visible_packages_heldback = true + no_packages_heldback = true lpadding = 2 package_statuses = PackageStatusData[] @@ -1903,7 +1905,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie latest_version = true # Outdated info cinfo = nothing - if !is_stdlib(new.uuid) + if !isnothing(new) && !is_stdlib(new.uuid) cinfo = status_compat_info(new, env, registries) if cinfo !== nothing latest_version = false @@ -1924,15 +1926,16 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie # allow space in the gutter for two icons on a single line lpadding = 3 end - - all_packages_downloaded &= pkg_downloaded - no_packages_upgradable &= !pkg_upgradable - no_packages_held_back &= !pkg_heldback - push!(package_statuses, PackageStatusData(uuid, old, new, pkg_downloaded, pkg_upgradable, pkg_heldback, cinfo)) + changed = old != new + all_packages_downloaded &= (!changed || pkg_downloaded) + no_packages_upgradable &= (!changed || !pkg_upgradable) + no_visible_packages_heldback &= (!changed || !pkg_heldback) + no_packages_heldback &= !pkg_heldback + push!(package_statuses, PackageStatusData(uuid, old, new, pkg_downloaded, pkg_upgradable, pkg_heldback, cinfo, changed)) end for pkg in package_statuses - pkg.old == pkg.new && continue # don't print packages that didn't change + pkg.changed || continue # don't print packages that didn't change if !pkg.downloaded print(io, not_installed_indicator) elseif lpadding > 2 @@ -1968,20 +1971,20 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie end if !no_changes && !all_packages_downloaded - printpkgstyle(io, :Info, "packages marked with $not_installed_indicator are not downloaded, use `instantiate` to download", ignore_indent) + printpkgstyle(io, :Info, "Packages marked with $not_installed_indicator are not downloaded, use `instantiate` to download", ignore_indent) end if !outdated && (mode != PKGMODE_COMBINED || (manifest == true)) - if !no_changes && !no_packages_upgradable && no_packages_held_back - printpkgstyle(io, :Info, "packages marked with $upgradable_indicator have new versions available", ignore_indent) + if !no_packages_upgradable && no_visible_packages_heldback + printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator have new versions available", ignore_indent) end - if !no_changes && !no_packages_held_back && no_packages_upgradable - printpkgstyle(io, :Info, "packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + if !no_visible_packages_heldback && no_packages_upgradable + printpkgstyle(io, :Info, "Packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) end - if !no_changes && !no_packages_held_back && !no_packages_upgradable - printpkgstyle(io, :Info, "packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) + if !no_visible_packages_heldback && !no_packages_upgradable + printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) end - if no_changes && diff && !no_packages_held_back - printpkgstyle(io, :Info, "some packages have new versions but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + if header == :Updating && no_visible_packages_heldback && !no_packages_heldback + printpkgstyle(io, :Info, "Some packages have new versions but cannot be upgraded. To see why use `status --outdated`", ignore_indent) end end diff --git a/test/new.jl b/test/new.jl index 1cfe32abfa..f3a3ccbb48 100644 --- a/test/new.jl +++ b/test/new.jl @@ -2115,15 +2115,15 @@ end @test occursin(r"Status `.+Project.toml`", readline(io)) @test occursin(r"→⌃ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) - @test "Info packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) - @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) + @test "Info Packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) + @test "Info Packages marked with ⌃ have new versions available" == strip(readline(io)) Pkg.status(;io=io, mode=Pkg.PKGMODE_MANIFEST) @test occursin(r"Status `.+Manifest.toml`", readline(io)) @test occursin(r"→⌃ \[7876af07\] Example\s*v\d\.\d\.\d", readline(io)) @test occursin(r"\[2a0f44e3\] Base64", readline(io)) @test occursin(r"\[d6f4376e\] Markdown", readline(io)) - @test "Info packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) - @test "Info packages marked with ⌃ have new versions available" == strip(readline(io)) + @test "Info Packages marked with → are not downloaded, use `instantiate` to download" == strip(readline(io)) + @test "Info Packages marked with ⌃ have new versions available" == strip(readline(io)) end # Manifest Status API isolate(loaded_depot=true) do @@ -2174,12 +2174,14 @@ end @test occursin(r"Diff `.+Project\.toml`", readline(io)) @test occursin(r"\[7876af07\] \+ Example\s*v0\.3\.0", readline(io)) @test occursin(r"\[d6f4376e\] - Markdown", readline(io)) + @test occursin("Info Packages marked with ⌃ have new versions available", readline(io)) ## diff manifest Pkg.status(; io=io, mode=Pkg.PKGMODE_MANIFEST, diff=true) @test occursin(r"Diff `.+Manifest.toml`", readline(io)) @test occursin(r"\[7876af07\] \+ Example\s*v0\.3\.0", readline(io)) @test occursin(r"\[2a0f44e3\] - Base64", readline(io)) @test occursin(r"\[d6f4376e\] - Markdown", readline(io)) + @test occursin("Info Packages marked with ⌃ have new versions available", readline(io)) ## diff project with filtering Pkg.status("Markdown"; io=io, diff=true) @test occursin(r"Diff `.+Project\.toml`", readline(io)) From 47d4d25df858cff9da724c4322c98036e1ff18ad Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 3 Jan 2022 10:17:45 -0500 Subject: [PATCH 16/19] fix indenting, color formatting, show logic --- src/Operations.jl | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index fc5eaa0bd5..b9c813c483 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1299,7 +1299,7 @@ function up(ctx::Context, pkgs::Vector{PackageSpec}, level::UpgradeLevel; new_apply = download_source(ctx) download_artifacts(ctx.env, julia_version=ctx.julia_version, io=ctx.io) write_env(ctx.env; skip_writing_project) # write env before building - show_update(ctx.env, ctx.registries; io=ctx.io) + show_update(ctx.env, ctx.registries; io=ctx.io, hidden_upgrades_info = true) build_versions(ctx, union(new_apply, new_git)) end @@ -1862,10 +1862,11 @@ struct PackageStatusData end function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registries::Vector{Registry.RegistryInstance}, header::Symbol, - uuids::Vector, names::Vector; manifest=true, diff=false, ignore_indent::Bool, outdated::Bool, io::IO, mode::PackageMode) - not_installed_indicator = sprint((io, args) -> printstyled(io, args...; color=:red), "→", context=io) + uuids::Vector, names::Vector; manifest=true, diff=false, ignore_indent::Bool, outdated::Bool, io::IO, + mode::PackageMode, hidden_upgrades_info::Bool) + not_installed_indicator = sprint((io, args) -> printstyled(io, args...; color=Base.error_color()), "→", context=io) upgradable_indicator = sprint((io, args) -> printstyled(io, args...; color=:green), "⌃", context=io) - heldback_indicator = sprint((io, args) -> printstyled(io, args...; color=:normal), "⌅", context=io) + heldback_indicator = sprint((io, args) -> printstyled(io, args...; color=Base.info_color()), "⌅", context=io) filter = !isempty(uuids) || !isempty(names) # setup xs = diff_array(old_env, env; manifest=manifest) @@ -1935,17 +1936,20 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie end for pkg in package_statuses - pkg.changed || continue # don't print packages that didn't change + diff && !pkg.changed && continue # in diff mode don't print packages that didn't change + first_indicator_printed = false if !pkg.downloaded print(io, not_installed_indicator) + first_indicator_printed = true elseif lpadding > 2 print(io, " ") + first_indicator_printed = true end if pkg.upgradable print(io, upgradable_indicator) elseif pkg.heldback print(io, heldback_indicator) - else + elseif lpadding == 2 && !first_indicator_printed print(io, " ") end @@ -1971,20 +1975,20 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie end if !no_changes && !all_packages_downloaded - printpkgstyle(io, :Info, "Packages marked with $not_installed_indicator are not downloaded, use `instantiate` to download", ignore_indent) + printpkgstyle(io, :Info, "Packages marked with $not_installed_indicator are not downloaded, use `instantiate` to download", color=Base.info_color(), ignore_indent) end if !outdated && (mode != PKGMODE_COMBINED || (manifest == true)) if !no_packages_upgradable && no_visible_packages_heldback - printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator have new versions available", ignore_indent) + printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator have new versions available", color=Base.info_color(), ignore_indent) end if !no_visible_packages_heldback && no_packages_upgradable - printpkgstyle(io, :Info, "Packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + printpkgstyle(io, :Info, "Packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) end if !no_visible_packages_heldback && !no_packages_upgradable - printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", ignore_indent) + printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) end - if header == :Updating && no_visible_packages_heldback && !no_packages_heldback - printpkgstyle(io, :Info, "Some packages have new versions but cannot be upgraded. To see why use `status --outdated`", ignore_indent) + if hidden_upgrades_info && no_visible_packages_heldback && !no_packages_heldback + printpkgstyle(io, :Info, "Some packages have new versions but cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) end end @@ -2008,17 +2012,17 @@ function git_head_env(env, project_dir) end end -function show_update(env::EnvCache, registries::Vector{Registry.RegistryInstance}; io::IO) +function show_update(env::EnvCache, registries::Vector{Registry.RegistryInstance}; io::IO, hidden_upgrades_info = false) old_env = EnvCache() old_env.project = env.original_project old_env.manifest = env.original_manifest - status(env, registries; header=:Updating, mode=PKGMODE_COMBINED, env_diff=old_env, ignore_indent=false, io=io) + status(env, registries; header=:Updating, mode=PKGMODE_COMBINED, env_diff=old_env, ignore_indent=false, io=io, hidden_upgrades_info) return nothing end function status(env::EnvCache, registries::Vector{Registry.RegistryInstance}, pkgs::Vector{PackageSpec}=PackageSpec[]; header=nothing, mode::PackageMode=PKGMODE_PROJECT, git_diff::Bool=false, env_diff=nothing, ignore_indent=true, - io::IO, outdated::Bool=false) + io::IO, outdated::Bool=false, hidden_upgrades_info::Bool=false) io == Base.devnull && return # if a package, print header if header === nothing && env.pkg !== nothing @@ -2045,10 +2049,10 @@ function status(env::EnvCache, registries::Vector{Registry.RegistryInstance}, pk diff = old_env !== nothing header = something(header, diff ? :Diff : :Status) if mode == PKGMODE_PROJECT || mode == PKGMODE_COMBINED - print_status(env, old_env, registries, header, filter_uuids, filter_names; manifest=false, diff, ignore_indent, io, outdated, mode) + print_status(env, old_env, registries, header, filter_uuids, filter_names; manifest=false, diff, ignore_indent, io, outdated, mode, hidden_upgrades_info) end if mode == PKGMODE_MANIFEST || mode == PKGMODE_COMBINED - print_status(env, old_env, registries, header, filter_uuids, filter_names; diff, ignore_indent, io, outdated, mode) + print_status(env, old_env, registries, header, filter_uuids, filter_names; diff, ignore_indent, io, outdated, mode, hidden_upgrades_info) end if is_manifest_current(env) === false printpkgstyle(io, :Warning, """The project dependencies or compat requirements have changed since the manifest was last resolved. \ From 953f936d20bdc9b72c5eb2e21521eab6283c8180 Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 3 Jan 2022 10:36:04 -0500 Subject: [PATCH 17/19] minor fix --- src/Operations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index b9c813c483..b90e6111fb 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1985,7 +1985,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie printpkgstyle(io, :Info, "Packages marked with $heldback_indicator have new versions available but cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) end if !no_visible_packages_heldback && !no_packages_upgradable - printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with ⌅ cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) + printpkgstyle(io, :Info, "Packages marked with $upgradable_indicator and $heldback_indicator have new versions available, but those with $heldback_indicator cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) end if hidden_upgrades_info && no_visible_packages_heldback && !no_packages_heldback printpkgstyle(io, :Info, "Some packages have new versions but cannot be upgraded. To see why use `status --outdated`", color=Base.info_color(), ignore_indent) From d398524f65ad64f390d423ce648807a9b8c0ad58 Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 3 Jan 2022 15:09:50 -0500 Subject: [PATCH 18/19] make heldback yellow --- src/Operations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index b90e6111fb..31ccd2b9df 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1866,7 +1866,7 @@ function print_status(env::EnvCache, old_env::Union{Nothing,EnvCache}, registrie mode::PackageMode, hidden_upgrades_info::Bool) not_installed_indicator = sprint((io, args) -> printstyled(io, args...; color=Base.error_color()), "→", context=io) upgradable_indicator = sprint((io, args) -> printstyled(io, args...; color=:green), "⌃", context=io) - heldback_indicator = sprint((io, args) -> printstyled(io, args...; color=Base.info_color()), "⌅", context=io) + heldback_indicator = sprint((io, args) -> printstyled(io, args...; color=Base.warn_color()), "⌅", context=io) filter = !isempty(uuids) || !isempty(names) # setup xs = diff_array(old_env, env; manifest=manifest) From 06355d09ea4c98f8f19646bf350205f1e2cf030c Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 3 Jan 2022 16:04:17 -0500 Subject: [PATCH 19/19] revert docstring formatting and add new indicators --- src/Pkg.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pkg.jl b/src/Pkg.jl index d70b04b232..4d7af9a110 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -405,9 +405,9 @@ As an example, a status output like: ``` pkg> Pkg.status(; outdated=true) Status `Manifest.toml` - [a8cc5b0e] Crayons v2.0.0 [