Skip to content

Commit

Permalink
Merge pull request JuliaLang#11137 from ncnc/nc/pkg-optimization
Browse files Browse the repository at this point in the history
RFC: Speed up Pkg.update()
  • Loading branch information
jakebolewski committed May 6, 2015
2 parents c967bfa + f5cd1e3 commit 90f7cd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/pkg/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ function prefetch(pkg::AbstractString, url::AbstractString, sha1s::Vector)
end
end
Git.set_remote_url(url, dir=cache)
if !all(sha1->Git.iscommit(sha1, dir=cache), sha1s)
in_cache = Git.iscommit(sha1s, dir=cache)
if !all(in_cache)
info("Updating cache of $pkg...")
Git.success(`remote update`, dir=cache) ||
error("couldn't update $cache using `git remote update`")
in_cache = Git.iscommit(sha1s, dir=cache)
end
filter(sha1->!Git.iscommit(sha1, dir=cache), sha1s)
sha1s[!in_cache]
end
prefetch(pkg::AbstractString, url::AbstractString, sha1::AbstractString...) = prefetch(pkg, url, AbstractString[sha1...])

Expand Down
4 changes: 4 additions & 0 deletions base/pkg/git.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ attached(; dir="") = success(`symbolic-ref -q HEAD`, dir=dir)
branch(; dir="") = readchomp(`rev-parse --symbolic-full-name --abbrev-ref HEAD`, dir=dir)
head(; dir="") = readchomp(`rev-parse HEAD`, dir=dir)

function iscommit(sha1s::Vector; dir="")
indexin(sha1s,split(readchomp(`log --all --format=%H`, dir=dir),"\n")).!=0
end

immutable State
head::ASCIIString
index::ASCIIString
Expand Down

0 comments on commit 90f7cd0

Please sign in to comment.