Skip to content

Commit

Permalink
Merge pull request #13648 from JuliaLang/jcb/vbupdate
Browse files Browse the repository at this point in the history
More verbose Pkg.update() for checked out packages
  • Loading branch information
jakebolewski committed Oct 17, 2015
2 parents 3e0e063 + f0c911d commit c13128a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
5 changes: 2 additions & 3 deletions base/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function iscommit(id::AbstractString, repo::GitRepo)
end

""" git diff-index HEAD [-- <path>]"""
isdirty(repo::GitRepo, paths::AbstractString=""; cached::Bool=false) = isdiff(repo, Consts.HEAD_FILE, paths, cached=cached)
isdirty(repo::GitRepo, paths::AbstractString=""; cached::Bool=false) =
isdiff(repo, Consts.HEAD_FILE, paths, cached=cached)

""" git diff-index <treeish> [-- <path>]"""
function isdiff(repo::GitRepo, treeish::AbstractString, paths::AbstractString=""; cached::Bool=false)
Expand Down Expand Up @@ -186,8 +187,6 @@ function branch(repo::GitRepo)
head_ref = head(repo)
try
branch(head_ref)
catch
""
finally
finalize(head_ref)
end
Expand Down
44 changes: 33 additions & 11 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,40 +331,62 @@ function update(branch::AbstractString)
with(GitRepo, "METADATA") do repo
with(LibGit2.head(repo)) do h
if LibGit2.branch(h) != branch
LibGit2.isdirty(repo) && throw(PkgError("METADATA is dirty and not on $branch, bailing"))
LibGit2.isattached(repo) || throw(PkgError("METADATA is detached not on $branch, bailing"))
if LibGit2.isdirty(repo)
throw(PkgError("METADATA is dirty and not on $branch, bailing"))
end
if !LibGit2.isattached(repo)
throw(PkgError("METADATA is detached not on $branch, bailing"))
end
LibGit2.fetch(repo)
LibGit2.checkout_head(repo)
LibGit2.branch!(repo, branch, track="refs/remotes/origin/$branch")
LibGit2.merge!(repo)
end
end
LibGit2.fetch(repo)
LibGit2.merge!(repo, fastforward=true) || LibGit2.rebase!(repo, "origin/$branch")
ff_succeeded = LibGit2.merge!(repo, fastforward=true)
if !ff_succeeded
LibGit2.rebase!(repo, "origin/$branch")
end
end
avail = Read.available()
# this has to happen before computing free/fixed
for pkg in filter!(Read.isinstalled,collect(keys(avail)))
for pkg in filter(Read.isinstalled, collect(keys(avail)))
try
Cache.prefetch(pkg, Read.url(pkg), [a.sha1 for (v,a)=avail[pkg]])
catch err
warn("Package $pkg: unable to update cache\n$(err.msg)")
end
end
instd = Read.installed(avail)
free = Read.free(instd)
free = Read.free(instd)
for (pkg,ver) in free
Cache.prefetch(pkg, Read.url(pkg), [a.sha1 for (v,a)=avail[pkg]])
Cache.prefetch(pkg, Read.url(pkg), [a.sha1 for (v,a) in avail[pkg]])
end
fixed = Read.fixed(avail,instd)
for (pkg,ver) in fixed
ispath(pkg,".git") || continue
with(GitRepo, pkg) do repo
if LibGit2.isattached(repo) && !LibGit2.isdirty(repo)
info("Updating $pkg...")
@recover begin
LibGit2.fetch(repo)
LibGit2.merge!(repo, fastforward=true)
if LibGit2.isattached(repo)
if LibGit2.isdirty(repo)
warn("Package $pkg: skipping update (dirty)...")
else
prev_sha = string(LibGit2.head_oid(repo))
success = true
try
LibGit2.fetch(repo)
LibGit2.merge!(repo, fastforward=true)
catch err
show(err)
print('\n')
success = false
end
if success
post_sha = string(LibGit2.head_oid(repo))
branch = LibGit2.branch(repo)
info("Updating $pkg $branch...",
prev_sha != post_sha ? " $(prev_sha[1:8])$(post_sha[1:8])" : "")
end
end
end
end
Expand Down

0 comments on commit c13128a

Please sign in to comment.