diff --git a/REQUIRE b/REQUIRE index d5d6467..cbe39bf 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1 +1,2 @@ julia 0.4 +Compat 0.7.16 diff --git a/src/MetadataTools.jl b/src/MetadataTools.jl index 41e9da5..0be20cc 100644 --- a/src/MetadataTools.jl +++ b/src/MetadataTools.jl @@ -12,6 +12,8 @@ module MetadataTools export get_pkg, get_all_pkg, get_upper_limit, get_pkg_info +using Compat + #----------------------------------------------------------------------- """ @@ -21,8 +23,8 @@ Represents a version of a package in METADATA.jl """ immutable PkgMetaVersion ver::VersionNumber - sha::UTF8String - requires::Vector{UTF8String} + sha::Compat.UTF8String + requires::Vector{Compat.UTF8String} end function printer(io::IO, pmv::PkgMetaVersion) print(io, " ", pmv.ver, ",", pmv.sha[1:6]) @@ -37,8 +39,8 @@ Base.show( io::IO, pmv::PkgMetaVersion) = printer(io,pmv) Represents a packages entry in METADATA.jl """ immutable PkgMeta - name::UTF8String - url::UTF8String + name::Compat.UTF8String + url::Compat.UTF8String versions::Vector{PkgMetaVersion} end function printer(io::IO, pm::PkgMeta) @@ -78,7 +80,7 @@ function get_pkg(pkg_name::AbstractString; url_path = joinpath(pkg_path,"url") !isfile(url_path) && error("Couldn't find url for $pkg_name (expected $url_path)") - url = chomp(readall(url_path)) + url = chomp(readstring(url_path)) vers_path = joinpath(pkg_path,"versions") !isdir(vers_path) && @@ -89,11 +91,11 @@ function get_pkg(pkg_name::AbstractString; for dir in readdir(vers_path) ver_num = convert(VersionNumber, dir) ver_path = joinpath(vers_path, dir) - sha = strip(readall(joinpath(ver_path,"sha1"))) + sha = strip(readstring(joinpath(ver_path,"sha1"))) req_path = joinpath(ver_path,"requires") - reqs = UTF8String[] + reqs = Compat.UTF8String[] if isfile(req_path) - req_file = map(strip,split(readall(req_path),"\n")) + req_file = map(strip,split(readstring(req_path),"\n")) for req in req_file length(req) == 0 && continue req[1] == '#' && continue @@ -116,7 +118,7 @@ in the METADATA folder. function get_all_pkg(; meta_path=Pkg.dir("METADATA")) !isdir(meta_path) && error("Couldn't find METADATA folder at $meta_path") - pkgs = Dict{UTF8String,PkgMeta}() + pkgs = Dict{Compat.UTF8String,PkgMeta}() for fname in readdir(meta_path) # Skip files !isdir(joinpath(meta_path, fname)) && continue diff --git a/src/pkg_graph.jl b/src/pkg_graph.jl index a5fa61d..629bf59 100644 --- a/src/pkg_graph.jl +++ b/src/pkg_graph.jl @@ -20,8 +20,8 @@ package dependency graph. """ type PkgGraph adjlist::Vector{Vector{Int}} - pkgnames::Vector{UTF8String} - pkgname_idx::Dict{UTF8String,Int} + pkgnames::Vector{Compat.UTF8String} + pkgname_idx::Dict{Compat.UTF8String,Int} end """ @@ -54,10 +54,10 @@ Given a Dict{UTF8String,PkgMeta} (e.g., from `get_all_pkg`), build a directed graph with an edge from PkgA to PkgB iff PkgA directly requires PkgB. Alternatively reverse the direction of the edges if `reverse` is true. """ -function make_dep_graph(pkgs::Dict{UTF8String,PkgMeta}; reverse=false) +function make_dep_graph(pkgs::Dict{Compat.UTF8String,PkgMeta}; reverse=false) pkgnames = collect(keys(pkgs)) - pkgname_idx = Dict{UTF8String,Int}( - [pkgname => i for (i,pkgname) in enumerate(pkgnames)]) + pkgname_idx = Dict{Compat.UTF8String,Int}( + [(pkgname, i) for (i,pkgname) in enumerate(pkgnames)]) # TODO: Dict(pkgname=>i for ...) numpkg = length(pkgnames) adjlist = Vector{Int}[Vector{Int}() for pkgname in pkgnames] @@ -139,8 +139,8 @@ function get_pkg_dep_graph(pkgname::AbstractString, pg::PkgGraph; depth=Inf) end end # Build subgraph - new_pkgnames = UTF8String["" for i in 1:new_n] - new_pkgname_idx = Dict{UTF8String,Int}() + new_pkgnames = Compat.UTF8String["" for i in 1:new_n] + new_pkgname_idx = Dict{Compat.UTF8String,Int}() new_adjlist = Vector{Int}[Vector{Int}() for i in 1:new_n] for old_idx in 1:n !visited[old_idx] && continue