summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-07-25 22:51:03 -0500
committerTristan Sloughter <t@crashfast.com>2015-07-25 22:51:03 -0500
commite64671686fd3d6fbec3077de29c1f5efc059388b (patch)
treec30e825106e688de2d498fbba2017557ffe667a4
parentbe1b16aea5650b57e28a77db044be27096b60c64 (diff)
fix upgrade of newly added pkg dep from scm locked dep
-rw-r--r--src/rebar_prv_plugins_upgrade.erl17
-rw-r--r--src/rebar_prv_upgrade.erl13
-rw-r--r--src/rebar_utils.erl15
3 files changed, 20 insertions, 25 deletions
diff --git a/src/rebar_prv_plugins_upgrade.erl b/src/rebar_prv_plugins_upgrade.erl
index f67b7dc..dfc9990 100644
--- a/src/rebar_prv_plugins_upgrade.erl
+++ b/src/rebar_prv_plugins_upgrade.erl
@@ -79,7 +79,7 @@ upgrade(Plugin, State) ->
find_plugin(Plugin, Profiles, State) ->
ec_lists:search(fun(Profile) ->
Plugins = rebar_state:get(State, {plugins, Profile}, []),
- case find(list_to_atom(Plugin), Plugins) of
+ case rebar_utils:tup_find(list_to_atom(Plugin), Plugins) of
false ->
not_found;
P ->
@@ -87,21 +87,6 @@ find_plugin(Plugin, Profiles, State) ->
end
end, Profiles).
-find(_Plugin, []) ->
- false;
-find(Plugin, [Plugin | _Plugins]) ->
- Plugin;
-find(Plugin, [Plugin1 | Plugins]) when is_tuple(Plugin1) ->
- case element(1, Plugin1) =:= Plugin of
- true ->
- Plugin1;
- false ->
- find(Plugin, Plugins)
- end;
-find(Plugin, [_Plugin | Plugins]) ->
- find(Plugin, Plugins).
-
-
build_plugin(AppInfo, Apps, State) ->
Providers = rebar_state:providers(State),
AppDir = rebar_app_info:dir(AppInfo),
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl
index 49d5674..46aed9e 100644
--- a/src/rebar_prv_upgrade.erl
+++ b/src/rebar_prv_upgrade.erl
@@ -94,21 +94,16 @@ prepare_locks([Name|Names], Deps, Locks, Unlocks) ->
AtomName = binary_to_atom(Name, utf8),
case lists:keyfind(Name, 1, Locks) of
{_, _, 0} = Lock ->
- case {lists:keyfind(AtomName, 1, Deps), lists:member(AtomName, Deps)} of
- {false, false} ->
+ case rebar_utils:tup_find(AtomName, Deps) of
+ false ->
?PRV_ERROR({unknown_dependency, Name});
- {Dep, false} ->
- {Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks),
- prepare_locks(Names, Deps, NewLocks,
- [{Name, Source, 0} | NewUnlocks ++ Unlocks]);
- {false, true} -> % package as a single atom
- Dep = AtomName,
+ Dep ->
{Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks),
prepare_locks(Names, Deps, NewLocks,
[{Name, Source, 0} | NewUnlocks ++ Unlocks])
end;
{_, _, Level} = Lock when Level > 0 ->
- case lists:keyfind(AtomName, 1, Deps) of
+ case rebar_utils:tup_find(AtomName, Deps) of
false ->
?PRV_ERROR({transitive_dependency, Name});
Dep -> % Dep has been promoted
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index c8b9e10..04f1d09 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -56,6 +56,7 @@
wordsize/0,
tup_umerge/2,
tup_sort/1,
+ tup_find/2,
line_count/1,
set_httpc_options/0,
escape_chars/1,
@@ -264,6 +265,20 @@ tup_umerge([], Olds) ->
tup_umerge([New|News], Olds) ->
lists:reverse(umerge(News, Olds, [], New)).
+tup_find(_Elem, []) ->
+ false;
+tup_find(Elem, [Elem | _Elems]) ->
+ Elem;
+tup_find(Elem, [Elem1 | Elems]) when is_tuple(Elem1) ->
+ case element(1, Elem1) =:= Elem of
+ true ->
+ Elem1;
+ false ->
+ tup_find(Elem, Elems)
+ end;
+tup_find(Elem, [_Elem | Elems]) ->
+ tup_find(Elem, Elems).
+
%% This is equivalent to umerge2_2 in the stdlib, except we use the expanded
%% value/key only to compare
umerge(News, [Old|Olds], Merged, Cmp) when element(1, Cmp) == element(1, Old);