Browse Source

Avoid duplicating deps in discover phase

The deps are sorted and merged, but the merge function merges lists, not
elements. This yields deps that are duplicated and ran for multiple
times.

We first add proper sorts so the keymerge is guaranteed to be fine, and
then do a dedup run to get rid of duplicates if they happen to be.
pull/269/head
Fred Hebert 10 years ago
parent
commit
bc98ea22aa
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      src/rebar_app_discover.erl

+ 8
- 1
src/rebar_app_discover.erl View File

@ -48,7 +48,9 @@ merge_deps(AppInfo, State) ->
State1 = lists:foldl(fun(Profile, StateAcc) -> State1 = lists:foldl(fun(Profile, StateAcc) ->
AppProfDeps = rebar_state:get(AppState, {deps, Profile}, []), AppProfDeps = rebar_state:get(AppState, {deps, Profile}, []),
TopLevelProfDeps = rebar_state:get(StateAcc, {deps, Profile}, []), TopLevelProfDeps = rebar_state:get(StateAcc, {deps, Profile}, []),
ProfDeps2 = lists:keymerge(1, TopLevelProfDeps, AppProfDeps),
ProfDeps2 = dedup(lists:keymerge(1,
lists:keysort(1, TopLevelProfDeps),
lists:keysort(1, AppProfDeps))),
rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2) rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2)
end, State, lists:reverse(CurrentProfiles)), end, State, lists:reverse(CurrentProfiles)),
@ -166,3 +168,8 @@ create_app_info(AppDir, AppFile) ->
_ -> _ ->
error error
end. end.
dedup([]) -> [];
dedup([A]) -> [A];
dedup([H,H|T]) -> dedup([H|T]);
dedup([H|T]) -> [H|dedup(T)].

Loading…
Cancel
Save