summaryrefslogtreecommitdiff
path: root/src/rebar_prv_install_deps.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-08-18 11:52:39 -0400
committerFred Hebert <mononcqc@ferd.ca>2015-08-18 11:52:39 -0400
commite9cfbfb36b53d2fc6c7ca34bb49fe75fa112f770 (patch)
treef9c2f17bcfff90cf76ddef3540d6df48ab9bb14e /src/rebar_prv_install_deps.erl
parent89ccf5799557691889f01ed85b38ac63be227f4a (diff)
parent070f828e10a27288fc16d77dc28866eba403436f (diff)
Merge pull request #724 from tsloughter/upgrade_with_locks
properly update locks for deps and ignore skip messages for locks
Diffstat (limited to 'src/rebar_prv_install_deps.erl')
-rw-r--r--src/rebar_prv_install_deps.erl45
1 files changed, 16 insertions, 29 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 11a4250..8fb3b47 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -194,12 +194,16 @@ handle_profile_pkg_level(PkgDeps, AllApps, Seen, Upgrade, Locks, State) ->
{ok, [], []} ->
throw({rebar_digraph, no_solution});
{ok, [], Discarded} ->
- [warn_skip_pkg(Pkg, State) || Pkg <- Discarded, not(pkg_locked(Pkg, Locks))],
+ [warn_skip_pkg(Pkg, State) || Upgrade =:= false,
+ Pkg <- Discarded,
+ not(pkg_locked(Pkg, Locks))],
[];
{ok, Solution, []} ->
Solution;
{ok, Solution, Discarded} ->
- [warn_skip_pkg(Pkg, State) || Pkg <- Discarded, not(pkg_locked(Pkg, Locks))],
+ [warn_skip_pkg(Pkg, State) || Upgrade =:= false,
+ Pkg <- Discarded,
+ not(pkg_locked(Pkg, Locks))],
Solution
end,
@@ -218,7 +222,7 @@ cull_compile(TopSortedDeps, ProjectApps) ->
pkg_locked({_, Name, _, _}, Locks) ->
pkg_locked(Name, Locks);
-pkg_locked({_, Name, _}, Locks) ->
+pkg_locked({Name, _}, Locks) ->
pkg_locked(Name, Locks);
pkg_locked(Name, Locks) ->
false =/= lists:keyfind(Name, 1, Locks).
@@ -338,30 +342,12 @@ update_seen_src_dep(AppInfo, _Profile, _Level, SrcDeps, PkgDeps, SrcApps, State,
update_unseen_src_dep(AppInfo, Profile, Level, SrcDeps, PkgDeps, SrcApps, State, Upgrade, Seen, Locks) ->
{NewSeen, State1} = maybe_lock(Profile, AppInfo, Seen, State, Level),
- {NewSrcDeps, NewPkgDeps, NewSrcApps, State2, NewLocks}
- = case Upgrade of
- true ->
- handle_upgrade(AppInfo, Profile, SrcDeps, PkgDeps, SrcApps,
- Level, State1, Seen, Locks);
- _ ->
- {_, AppInfo1} = maybe_fetch(AppInfo, Profile, false, Seen, State1),
- handle_dep(AppInfo1, Profile, SrcDeps, PkgDeps, SrcApps,
- Level, State1, Locks)
- end,
+ {_, AppInfo1} = maybe_fetch(AppInfo, Profile, Upgrade, Seen, State1),
+ {NewSrcDeps, NewPkgDeps, NewSrcApps, State2, NewLocks} =
+ handle_dep(AppInfo1, Profile, SrcDeps, PkgDeps, SrcApps,
+ Level, State1, Locks),
{NewSrcDeps, NewPkgDeps, NewSrcApps, State2, NewSeen, NewLocks}.
-handle_upgrade(AppInfo, Profile, SrcDeps, PkgDeps, SrcApps, Level, State, Seen, Locks) ->
- Name = rebar_app_info:name(AppInfo),
- case lists:keyfind(Name, 1, Locks) of
- false ->
- {_, AppInfo1} = maybe_fetch(AppInfo, Profile, true, Seen, State),
- handle_dep(AppInfo1, Profile, SrcDeps, PkgDeps, SrcApps,
- Level, State, Locks);
- _StillLocked ->
- handle_dep(AppInfo, Profile, SrcDeps, PkgDeps, SrcApps,
- Level, State, Locks)
- end.
-
handle_dep(AppInfo, Profile, SrcDeps, PkgDeps, SrcApps, Level, State, Locks) ->
DepsDir = profile_dep_dir(State, Profile),
{AppInfo1, NewSrcDeps, NewPkgDeps, NewLocks, State1} =
@@ -399,11 +385,12 @@ handle_dep(State, Profile, DepsDir, AppInfo, Locks, Level) ->
%% Upgrade lock level to be the level the dep will have in this dep tree
Deps = rebar_state:get(S5, {deps, default}, []),
- NewLocks = [{DepName, Source, LockLevel+Level} ||
- {DepName, Source, LockLevel} <- rebar_state:get(S5, {locks, default}, [])],
+ NewLocks = Locks++[{DepName, Source, LockLevel+Level} ||
+ {DepName, Source, LockLevel} <- rebar_state:get(S5, {locks, default}, [])],
AppInfo3 = rebar_app_info:deps(AppInfo2, rebar_state:deps_names(Deps)),
- {SrcDeps, PkgDeps} = parse_deps(rebar_app_info:name(AppInfo3), DepsDir, Deps, S5, Locks, Level+1),
- {AppInfo3, SrcDeps, PkgDeps, Locks++NewLocks, State}.
+ {SrcDeps, PkgDeps} = parse_deps(rebar_app_info:name(AppInfo3), DepsDir, Deps
+ ,S5, NewLocks, Level+1),
+ {AppInfo3, SrcDeps, PkgDeps, NewLocks, State}.
-spec maybe_fetch(rebar_app_info:t(), atom(), boolean(),
sets:set(binary()), rebar_state:t()) -> {boolean(), rebar_app_info:t()}.