diff options
author | Tristan Sloughter <[email protected]> | 2014-07-07 20:50:45 -0500 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2014-07-09 12:24:46 -0500 |
commit | 11b4775c6610bd8f1c00d45e0766423301927b45 (patch) | |
tree | aada3fbf4f2d5b000876dfd0d374ac3b0d8e0782 /src | |
parent | 13a76fa25a67cc6d9e3a1192d5acc90d36a81585 (diff) | |
download | relx-11b4775c6610bd8f1c00d45e0766423301927b45.tar.gz relx-11b4775c6610bd8f1c00d45e0766423301927b45.tar.bz2 relx-11b4775c6610bd8f1c00d45e0766423301927b45.zip |
sort apps by version, so newest is chosen if it passes constraints
Diffstat (limited to 'src')
-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 [] -> |