From 0aac824f7191d541978736e2e8762f34ae260ec3 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 30 May 2021 18:38:35 -0400 Subject: [PATCH 1/7] change default manifest format to v2 --- src/Types.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types.jl b/src/Types.jl index 2240074811..d6f4e4b684 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -262,7 +262,7 @@ Base.hash(x::PackageEntry, h::UInt) = foldr(hash, [x.name, x.version, x.path, x. Base.@kwdef mutable struct Manifest julia_version::Union{Nothing,VersionNumber} = Base.VERSION - manifest_format::VersionNumber = v"1.0.0" # default to older flat format + manifest_format::VersionNumber = v"2.0.0" deps::Dict{UUID,PackageEntry} = Dict{UUID,PackageEntry}() other::Dict{String,Any} = Dict{String,Any}() end From 140128438d104aa05ff15ac421d72c5f3a31ec74 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 30 May 2021 18:39:01 -0400 Subject: [PATCH 2/7] warn if older format Manifest.toml is being maintained --- src/manifest.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/manifest.jl b/src/manifest.jl index 5f85fa5520..bd82064359 100644 --- a/src/manifest.jl +++ b/src/manifest.jl @@ -281,6 +281,12 @@ function write_manifest(env::EnvCache) write_manifest(env.manifest, env.manifest_file) end function write_manifest(manifest::Manifest, manifest_file::AbstractString) + if manifest.manifest_format.major == 1 + @warn """The active manifest file has an old format that is being maintained. + To update to the new format: + 1. Delete the manifest file at `$(manifest_file)` + 2. Run `import Pkg; Pkg.resolve()`""" maxlog = 1 + end return write_manifest(destructure(manifest), manifest_file) end function write_manifest(io::IO, manifest::Manifest) From b42cc3ac56c9bc80d2712d1df161e73053eaf9f0 Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 31 May 2021 21:56:06 -0400 Subject: [PATCH 3/7] update tests for new manifest defaults --- test/manifests.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/manifests.jl b/test/manifests.jl index 6f20f6b0ea..30a792bb99 100644 --- a/test/manifests.jl +++ b/test/manifests.jl @@ -5,7 +5,7 @@ import ..Pkg, LibGit2 using ..Utils @testset "Manifest.toml formats" begin - @testset "Default manifest format is v1" begin + @testset "Default manifest format is v2" begin isolate(loaded_depot=true) do io = IOBuffer() Pkg.activate(; io=io, temp=true) @@ -13,7 +13,8 @@ using ..Utils @test occursin(r"Activating.*project at.*", output) Pkg.add("Profile") env_manifest = Pkg.Types.Context().env.manifest_file - @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) + @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false + @test Pkg.Types.Context().env.manifest.manifest_format == v"2.0.0" end end From 8eced455512ab57eca1f4cd06f308403fc69d514 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 3 Jun 2021 01:12:29 -0400 Subject: [PATCH 4/7] add Pkg.upgrade_manifest() --- src/API.jl | 13 +++++++++++++ src/Pkg.jl | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/API.jl b/src/API.jl index 9ddac45f37..a551ec9f70 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1670,4 +1670,17 @@ function handle_package_input!(pkg::PackageSpec) pkg.uuid = pkg.uuid isa String ? UUID(pkg.uuid) : pkg.uuid end +function upgrade_manifest(ctx::Context = Context()) + before_format = ctx.env.manifest.manifest_format + if before_format == v"2.0" + pkgerror("Format of manifest file at `$(ctx.env.manifest_file)` already up to date: manifest_format == $(before_format)") + elseif before_format != v"1.0" + pkgerror("Format of manifest file at `$(ctx.env.manifest_file)` version is unrecogized: manifest_format == $(before_format)") + end + ctx.env.manifest.manifest_format = v"2.0" + Types.write_manifest(ctx.env) + printpkgstyle(ctx.io, :Updated, "Format of manifest file at `$(ctx.env.manifest_file)` updated from v$(before_format.major).$(before_format.minor) to v2.0") + return nothing +end + end # module diff --git a/src/Pkg.jl b/src/Pkg.jl index 34ff54c01d..619c2c56c9 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -559,6 +559,13 @@ Below is a comparison between the REPL mode and the functional API:: """ const RegistrySpec = Registry.RegistrySpec +""" + upgrade_manifest() + upgrade_manifest(ctx::Context) + +Upgrades the format of the manifest file from v1.0 to v2.0 without re-resolving. +""" +const upgrade_manifest = API.upgrade_manifest function __init__() if isdefined(Base, :active_repl) From 3a36474c7bcb67426a8a092f5cdc9977a9f783b2 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 3 Jun 2021 01:14:54 -0400 Subject: [PATCH 5/7] update warning advice --- src/manifest.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/manifest.jl b/src/manifest.jl index bd82064359..9dbee98a68 100644 --- a/src/manifest.jl +++ b/src/manifest.jl @@ -282,10 +282,8 @@ function write_manifest(env::EnvCache) end function write_manifest(manifest::Manifest, manifest_file::AbstractString) if manifest.manifest_format.major == 1 - @warn """The active manifest file has an old format that is being maintained. - To update to the new format: - 1. Delete the manifest file at `$(manifest_file)` - 2. Run `import Pkg; Pkg.resolve()`""" maxlog = 1 + @warn """The active manifest file at `$(manifest_file)` has an old format that is being maintained. + To update to the new format run `Pkg.upgrade_manifest()` which will upgrade the format without re-resolving""" maxlog = 1 end return write_manifest(destructure(manifest), manifest_file) end From 0d0fbaeb4fbc6219efb5404974ef3b6510baccc0 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Mon, 7 Jun 2021 08:55:03 +0200 Subject: [PATCH 6/7] also set version for new manifest --- src/API.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/API.jl b/src/API.jl index a551ec9f70..36eb4ac9d0 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1678,6 +1678,7 @@ function upgrade_manifest(ctx::Context = Context()) pkgerror("Format of manifest file at `$(ctx.env.manifest_file)` version is unrecogized: manifest_format == $(before_format)") end ctx.env.manifest.manifest_format = v"2.0" + ctx.env.manifest.julia_version = VERSION Types.write_manifest(ctx.env) printpkgstyle(ctx.io, :Updated, "Format of manifest file at `$(ctx.env.manifest_file)` updated from v$(before_format.major).$(before_format.minor) to v2.0") return nothing From 99793d0e23c5ff1dce9deac7039df00fc7bd18bb Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Mon, 7 Jun 2021 09:32:54 +0200 Subject: [PATCH 7/7] remove docstring for undocumented Context type --- src/Pkg.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Pkg.jl b/src/Pkg.jl index 619c2c56c9..d446ae799b 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -561,7 +561,6 @@ const RegistrySpec = Registry.RegistrySpec """ upgrade_manifest() - upgrade_manifest(ctx::Context) Upgrades the format of the manifest file from v1.0 to v2.0 without re-resolving. """