@@ -76,26 +76,28 @@ function compress(path::AbstractString, uncompressed::Dict,
7676 inverted = Dict {Pair{String,Any},Vector{VersionNumber}} ()
7777 for (ver, data) in uncompressed, (key, val) in data
7878 val isa Base. UUID && (val = string (val))
79- # Existing version ranges in `Compat.toml` files are stored without spaces.
80- # New version ranges are added with spaces in their string representation.
81- # Remove all spaces, so that equal version ranges compare equal as strings.
82- # This is a temporary work-around that will become unnecessary when
83- # "all this is rewritten to use VersionNumbers", as suggested above.
84- #
85- # The source of the spaces is https://github.com/JuliaLang/Pkg.jl/pull/3580.
86- val = replace (string (val), " " => " " )
87- push! (get! (inverted, key => val, VersionNumber[]), ver)
79+ push! (get! (inverted, key => unspace_hyphen (val), VersionNumber[]), ver)
8880 end
8981 compressed = Dict {String,Dict{String,Any}} ()
9082 for ((k, v), vers) in inverted
9183 for r in compress_versions (versions, sort! (vers)). ranges
92- # Remove the version range spaces also in the keys.
93- get! (compressed, replace (string (r), " " => " " ), Dict {String,Any} ())[k] = v
84+ get! (compressed, unspace_hyphen (string (r)), Dict {String, Any} ())[k] = v
9485 end
9586 end
9687 return compressed
9788end
9889
90+ # Existing version ranges in `Compat.toml` files are stored without spaces
91+ # around hyphens. New version ranges are added with spaces in their string
92+ # representation. Remove all spaces, so that equal version ranges compare
93+ # equal as strings. This is a temporary work-around that will become
94+ # unnecessary when "all this is rewritten to use VersionNumbers", as
95+ # suggested above.
96+ #
97+ # The source of the spaces is https://github.com/JuliaLang/Pkg.jl/pull/3580.
98+ unspace_hyphen (x:: AbstractString ) = replace (x, " - " => " -" )
99+ unspace_hyphen (x:: AbstractVector ) = unspace_hyphen .(x)
100+
99101function save (path:: AbstractString , uncompressed:: Dict ,
100102 versions:: Vector{VersionNumber} = load_versions (path))
101103 compressed = compress (path, uncompressed)
0 commit comments