diff options
author | Jordan Wilberding <[email protected]> | 2014-08-09 20:29:31 -0700 |
---|---|---|
committer | Jordan Wilberding <[email protected]> | 2014-08-09 20:29:31 -0700 |
commit | 1d7f26d786452f53a77fba64fe5081885d26856f (patch) | |
tree | b256b3c4ba3db142c92d037438b7e2f50052a205 /src/rlx_depsolver.erl | |
parent | f8737c88f54aaa8f2e9a4b66bb74034f0a3bbab1 (diff) | |
parent | 11b4775c6610bd8f1c00d45e0766423301927b45 (diff) | |
download | relx-1d7f26d786452f53a77fba64fe5081885d26856f.tar.gz relx-1d7f26d786452f53a77fba64fe5081885d26856f.tar.bz2 relx-1d7f26d786452f53a77fba64fe5081885d26856f.zip |
Merge pull request #207 from tsloughter/app_sort
sort apps by version, so newest is chosen if it passes constraints
Diffstat (limited to 'src/rlx_depsolver.erl')
-rw-r--r-- | src/rlx_depsolver.erl | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/rlx_depsolver.erl b/src/rlx_depsolver.erl index e054cc9..f9dc73d 100644 --- a/src/rlx_depsolver.erl +++ b/src/rlx_depsolver.erl @@ -214,14 +214,20 @@ add_package_version({?MODULE, Dom0}, RawPkg, RawVsn, RawPkgConstraints) -> Info2 = case gb_trees:lookup(Pkg, Dom0) of {value, Info0} -> - case lists:keytake(Vsn, 1, Info0) of - {value, {Vsn, Constraints}, Info1} -> - [{Vsn, join_constraints(Constraints, - PkgConstraints)} - | Info1]; - false -> - [{Vsn, PkgConstraints} | Info0] - end; + %% Sort Vsns from greatest to lowest + lists:reverse( + lists:sort(fun(X, Y) -> + ec_semver:lte(element(1, X), element(1, Y)) + end, + case lists:keytake(Vsn, 1, Info0) of + {value, {Vsn, Constraints}, Info1} -> + [{Vsn, join_constraints(Constraints, + PkgConstraints)} + | Info1]; + false -> + [{Vsn, PkgConstraints} | Info0] + + end)); none -> [{Vsn, PkgConstraints}] end, @@ -621,7 +627,6 @@ pkgs(DepGraph, Visited, Pkg, Constraints, OtherPkgs, PathInd) -> NewVisited = [{Pkg, Vsn} | Visited], Res = all_pkgs(DepGraph, NewVisited, DepPkgs ++ OtherPkgs, UConstraints, PathInd), Res - end, case constrained_package_versions(DepGraph, Pkg, Constraints) of [] -> |