Skip to content

Commit

Permalink
Convert libgit2 to use new logging
Browse files Browse the repository at this point in the history
  • Loading branch information
c42f committed Sep 28, 2017
1 parent b4ec443 commit 6ddb8ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
2 changes: 1 addition & 1 deletion base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
set!(cfg, "branch.$branch_name.merge", name(Base.get(branch_ref)))
end
catch
warn("Please provide remote tracking for branch '$branch_name' in '$(path(repo))'")
@warn "Please provide remote tracking for branch \"$branch_name\"" repo
end
end

Expand Down
8 changes: 4 additions & 4 deletions base/libgit2/merge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function merge!(repo::GitRepo, anns::Vector{GitAnnotated};
Ptr{MergeOptions}, Ptr{CheckoutOptions}),
repo.ptr, map(x->x.ptr, anns), anns_size,
Ref(merge_opts), Ref(checkout_opts))
info("Review and commit merged changes.")
@info "Review and commit merged changes."
return true
end

Expand Down Expand Up @@ -206,7 +206,7 @@ function merge!(repo::GitRepo, anns::Vector{GitAnnotated}, fastforward::Bool;
merge_result = if ffpref == Consts.MERGE_PREFERENCE_NONE
if isset(ma, Cint(Consts.MERGE_ANALYSIS_FASTFORWARD))
if length(anns) > 1
warn("Unable to perform Fast-Forward merge with mith multiple merge heads.")
@warn "Unable to perform Fast-Forward merge with mith multiple merge heads." repo
false
else
ffmerge!(repo, anns[1])
Expand All @@ -219,13 +219,13 @@ function merge!(repo::GitRepo, anns::Vector{GitAnnotated}, fastforward::Bool;
elseif ffpref == Consts.MERGE_PREFERENCE_FASTFORWARD_ONLY
if isset(ma, Cint(Consts.MERGE_ANALYSIS_FASTFORWARD))
if length(anns) > 1
warn("Unable to perform Fast-Forward merge with mith multiple merge heads.")
@warn "Unable to perform Fast-Forward merge with mith multiple merge heads." repo
false
else
ffmerge!(repo, anns[1])
end
else
warn("Cannot perform fast-forward merge.")
@warn "Cannot perform fast-forward merge." repo
false
end
elseif ffpref == Consts.MERGE_PREFERENCE_NO_FASTFORWARD
Expand Down
18 changes: 0 additions & 18 deletions base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1003,24 +1003,6 @@ end

with(f::Function, ::Type{T}, args...) where {T} = with(f, T(args...))

"""
with_warn(f::Function, ::Type{T}, args...)
Resource management helper function. Apply `f` to `args`, first constructing
an instance of type `T` from `args`. Makes sure to call `close` on the resulting
object after `f` successfully returns or throws an error. Ensures that
allocated git resources are finalized as soon as they are no longer needed. If an
error is thrown by `f`, a warning is shown containing the error.
"""
function with_warn(f::Function, ::Type{T}, args...) where T
obj = T(args...)
try
with(f, obj)
catch err
warn("$(string(T)) thrown exception: $err")
end
end

"""
LibGit2.Consts.OBJECT(::Type{T}) where T<:GitObject
Expand Down

0 comments on commit 6ddb8ce

Please sign in to comment.