diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-04-24 02:54:37 +0000 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-04-24 02:54:37 +0000 |
commit | 5d1634448cb89cd4c0b6f49e757ef281d5e71205 (patch) | |
tree | fbb2a4ae8615ab18077786c565bf87538b532a3c /src | |
parent | 578a27f506a00615f41803c277cc3069a7f3022a (diff) |
handle transitive deps being promoted
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_upgrade.erl | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl index 37914a7..d7d2921 100644 --- a/src/rebar_prv_upgrade.erl +++ b/src/rebar_prv_upgrade.erl @@ -91,29 +91,38 @@ parse_names(Bin, Locks) -> prepare_locks([], _, Locks, Unlocks) -> {Locks, Unlocks}; prepare_locks([Name|Names], Deps, Locks, Unlocks) -> + AtomName = binary_to_atom(Name, utf8), case lists:keyfind(Name, 1, Locks) of {_, _, 0} = Lock -> - AtomName = binary_to_atom(Name, utf8), case lists:keyfind(AtomName, 1, Deps) of false -> ?PRV_ERROR({unknown_dependency, Name}); Dep -> - Source = case Dep of - {_, Src} -> Src; - {_, _, Src} -> Src - end, - {NewLocks, NewUnlocks} = unlock_higher_than(0, Locks -- [Lock]), - prepare_locks(Names, - Deps, - NewLocks, + {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 + false -> + ?PRV_ERROR({transitive_dependency, Name}); + Dep -> % Dep has been promoted + {Source, NewLocks, NewUnlocks} = prepare_lock(Dep, Lock, Locks), + prepare_locks(Names, Deps, NewLocks, [{Name, Source, 0} | NewUnlocks ++ Unlocks]) end; - {_, _, Level} when Level > 0 -> - ?PRV_ERROR({transitive_dependency, Name}); false -> ?PRV_ERROR({unknown_dependency, Name}) end. +prepare_lock(Dep, Lock, Locks) -> + Source = Source = case Dep of + {_, Src} -> Src; + {_, _, Src} -> Src + end, + {NewLocks, NewUnlocks} = unlock_higher_than(0, Locks -- [Lock]), + {Source, NewLocks, NewUnlocks}. + top_level_deps(Deps, Locks) -> [Dep || Dep <- Deps, lists:keymember(0, 3, Locks)]. |