Improve cost function

It's still not really correct to do it this way, but it passes the
existing tests now.

In particular, we now prioritize making top-level dependencies
newer over making indirect dependencies older.  However, this
approach is flawed because we only visit the packages in the
original solution, before optimization.  We should assign a cost
to every package version that might be chosen, and let the solver
shift things around arbitrarily.
This commit is contained in:
David Greenspan
2015-01-28 14:18:21 -08:00
parent 43f33723a5
commit d1cefb2c9b

View File

@@ -167,7 +167,17 @@ var newResolveWithInput = function (input, _nudge) {
}
return false;
});
} else {
}
}
});
_.each(solution.getTrueVars(), function (x) {
if (x.indexOf(' ') >= 0) {
var pv = CS.PackageAndVersion.fromString(x);
var package = pv.package;
var version = pv.version;
var otherVersions = cache.getPackageVersions(package); // sorted
if (! _.has(rootDeps, package)) {
// try to make older
otherVersions = _.clone(otherVersions);
otherVersions.reverse();