diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-04-29 11:20:42 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-04-29 11:20:42 -0400 |
commit | 7645a1118f0e5cdc27e010905f5072021559ddfd (patch) | |
tree | 4215048997e799e67dbd926f0c1ce9d46d54ceac | |
parent | 212b23b889c0189d3f609d5a16781f6acbadf824 (diff) | |
parent | bce924e04ad087465370e851324896a892bfc690 (diff) |
Merge pull request #378 from tsloughter/loading_registry
don't load package registry unless there are pkg deps to solve
-rw-r--r-- | src/rebar_prv_install_deps.erl | 35 | ||||
-rw-r--r-- | test/mock_pkg_resource.erl | 2 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 4 |
3 files changed, 25 insertions, 16 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index e25e2c5..17346f4 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -128,30 +128,39 @@ handle_deps(Profile, State, Deps, Locks) when is_list(Locks) -> handle_deps(_Profile, State, [], _, _) -> {ok, [], State}; handle_deps(Profile, State0, Deps, Upgrade, Locks) -> - %% Read in package index and dep graph - {Packages, Graph} = rebar_state:packages(State0), - Registry = rebar_packages:registry(State0), - State = rebar_state:packages(rebar_state:registry(State0, Registry), {Packages, Graph}), %% Split source deps from pkg deps, needed to keep backwards compatibility - DepsDir = profile_dep_dir(State, Profile), - {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps, State, Locks, 0), + DepsDir = profile_dep_dir(State0, Profile), + + {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps, State0, Locks, 0), %% Fetch transitive src deps - {State1, SrcApps, PkgDeps1, Seen} = - update_src_deps(Profile, 0, SrcDeps, PkgDeps, [], State, Upgrade, sets:new(), Locks), + {State1, SrcApps, PkgDeps1, Seen} = update_src_deps(Profile, 0, SrcDeps, PkgDeps, [] + ,State0, Upgrade, sets:new(), Locks), - {Solved, State2} = - update_pkg_deps(Profile, Packages, PkgDeps1, Graph, Upgrade, Seen, State1), + {Solved, State4} = + case PkgDeps1 of + [] -> + {[], State1}; + _ -> + %% Read in package index and dep graph + {Packages, Graph} = rebar_state:packages(State1), + Registry = rebar_packages:registry(State1), + State2 = rebar_state:packages(rebar_state:registry(State1, Registry) + ,{Packages, Graph}), + + update_pkg_deps(Profile, Packages, PkgDeps1 + ,Graph, Upgrade, Seen, State2) + end, AllDeps = lists:ukeymerge(2 ,lists:ukeysort(2, SrcApps) ,lists:ukeysort(2, Solved)), - State3 = rebar_state:update_all_deps(State2, AllDeps), + State5 = rebar_state:update_all_deps(State4, AllDeps), CodePaths = [rebar_app_info:ebin_dir(A) || A <- AllDeps], - State4 = rebar_state:update_code_paths(State3, all_deps, CodePaths), + State6 = rebar_state:update_code_paths(State5, all_deps, CodePaths), - {ok, AllDeps, State4}. + {ok, AllDeps, State6}. %% =================================================================== %% Internal functions diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl index 615e8a5..560caef 100644 --- a/test/mock_pkg_resource.erl +++ b/test/mock_pkg_resource.erl @@ -152,7 +152,7 @@ find_parts([{AppName, Deps}|Rest], Skip, Acc) -> end. to_graph_parts(Dict) -> - LastUpdated = now(), + LastUpdated = os:timestamp(), dict:fold(fun(K,V,{Ks,Vs}) -> {_,Deps} = lists:keyfind(<<"deps">>, 1, V), {[{K,LastUpdated}|Ks], diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index f764146..2cdc58b 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -104,12 +104,12 @@ create_config(AppDir, Contents) -> %% @doc Util to create a random variation of a given name. create_random_name(Name) -> - random:seed(erlang:now()), + random:seed(os:timestamp()), Name ++ erlang:integer_to_list(random:uniform(1000000)). %% @doc Util to create a random variation of a given version. create_random_vsn() -> - random:seed(erlang:now()), + random:seed(os:timestamp()), lists:flatten([erlang:integer_to_list(random:uniform(100)), ".", erlang:integer_to_list(random:uniform(100)), ".", erlang:integer_to_list(random:uniform(100))]). |