Skip to content

Commit

Permalink
use a separate path_resolve! functions
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Jan 29, 2018
1 parent 1243828 commit 5a30b4e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
55 changes: 22 additions & 33 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,38 +198,25 @@ function collect_fixed!(env, pkgs, uuids)
fix_deps_map = Dict{UUID,Vector{PackageSpec}}()
uuid_to_pkg = Dict{UUID,PackageSpec}()
for pkg in pkgs
path = nothing
version = nothing
has_path(pkg) && (path = pkg.path)
has_version(pkg) && (version = pkg.version)
info = manifest_info(env, pkg.uuid)
version == nothing && info != nothing && haskey(info, "version") && (version = VersionNumber(info["version"]))
path == nothing && info != nothing && haskey(info, "path") && (path = info["path"])
if path != nothing # This is a fixed package
# Package is actually being freed, so it is not fixed
pkg.beingfreed && continue
# A package with a path should have a version
@assert version != nothing
pkg.path = path
pkg.version = version

uuid_to_pkg[pkg.uuid] = pkg
# Load the dependencies if this package has a REQUIRE
# TODO: this is still using Pkg2 facilities
reqfile = joinpath(path, "REQUIRE")
fix_deps_map[pkg.uuid] = valtype(fix_deps_map)()
!isfile(reqfile) && continue
for r in filter!(r->r isa Pkg2.Reqs.Requirement, Pkg2.Reqs.read(reqfile))
# @assert length(r.versions.intervals) == 1
pkg_name, version = r.package, r.versions.intervals[1]
# Convert to Pkg3 data types
# TODO: the upper bound here is incorrect
vspec = VersionSpec([VersionRange(VersionBound(version.lower),
VersionBound(version.upper))])
deppkg = PackageSpec(pkg_name, vspec)
push!(fix_deps_map[pkg.uuid], deppkg)
push!(fix_deps, deppkg)
end
!has_path(pkg) && continue
# A package with a path should have a version
@assert pkg.version != nothing

uuid_to_pkg[pkg.uuid] = pkg
# Load the dependencies if this package has a REQUIRE
reqfile = joinpath(pkg.path, "REQUIRE")
fix_deps_map[pkg.uuid] = valtype(fix_deps_map)()
!isfile(reqfile) && continue
for r in filter!(r->r isa Pkg2.Reqs.Requirement, Pkg2.Reqs.read(reqfile))
# TODO: get all intervals
pkg_name, version = r.package, r.versions.intervals[1]
# Convert to Pkg3 data types
# TODO: the upper bound here is incorrect
vspec = VersionSpec([VersionRange(VersionBound(version.lower),
VersionBound(version.upper))])
deppkg = PackageSpec(pkg_name, vspec)
push!(fix_deps_map[pkg.uuid], deppkg)
push!(fix_deps, deppkg)
end
end

Expand Down Expand Up @@ -266,8 +253,10 @@ function resolve_versions!(env::EnvCache, pkgs::Vector{PackageSpec})::Dict{UUID,
ver = VersionNumber(info["version"])
push!(pkgs, PackageSpec(name, uuid, ver))
end
# construct data structures for resolver and call it
path_resolve!(env, pkgs)

reqs = Requires(pkg.uuid => pkg.version for pkg in pkgs if pkg.uuid uuid_julia)
# Collect all fixed packages (have a path) and their dependencies
fixed = collect_fixed!(env, pkgs, uuids)
fixed[uuid_julia] = Fixed(VERSION) # fix julia to current version
graph = deps_graph(env, uuid_to_name, reqs, fixed)
Expand Down
11 changes: 11 additions & 0 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,17 @@ function registry_resolve!(env::EnvCache, pkgs::AbstractVector{PackageSpec})
return pkgs
end


function path_resolve!(env::EnvCache, pkgs::AbstractVector{PackageSpec})
for pkg in pkgs
pkg.beingfreed && continue
info = manifest_info(env, pkg.uuid)
info == nothing && continue
haskey(info, "path") && (pkg.path = info["path"])
haskey(info, "version") && (pkg.version = VersionNumber(info["version"]))
end
end

"Ensure that all packages are fully resolved"
function ensure_resolved(
env::EnvCache,
Expand Down

0 comments on commit 5a30b4e

Please sign in to comment.