Only load packages as they are passed to resolve

(and their transitive dependencies)
This commit is contained in:
David Glasser
2014-07-23 16:17:54 -07:00
parent c7a1fdfead
commit d66da2575b

View File

@@ -20,10 +20,6 @@ ConstraintSolver.PackagesResolver = function (catalog, options) {
self._packageInfoLoadQueue = [];
self._packagesEverEnqueued = {};
self._loadingPackageInfo = false;
_.each(catalog.getAllPackageNames(), function (packageName) {
self._ensurePackageInfoLoaded(packageName);
});
};
ConstraintSolver.PackagesResolver.prototype._ensurePackageInfoLoaded = function (
@@ -125,8 +121,8 @@ ConstraintSolver.PackagesResolver.prototype._loadPackageInfo = function (
// than keeping the old version
// - previousSolution - mapping from package name to a version that was used in
// the previous constraint solver run
ConstraintSolver.PackagesResolver.prototype.resolve =
function (dependencies, constraints, options) {
ConstraintSolver.PackagesResolver.prototype.resolve = function (
dependencies, constraints, options) {
var self = this;
options = _.defaults(options || {}, {
@@ -144,6 +140,16 @@ ConstraintSolver.PackagesResolver.prototype.resolve =
previousSolution: Match.Optional(Object)
});
_.each(dependencies, function (packageName) {
self._ensurePackageInfoLoaded(packageName);
});
_.each(constraints, function (constraint) {
self._ensurePackageInfoLoaded(constraint.packageName);
});
_.each(options.previousSolution, function (version, packageName) {
self._ensurePackageInfoLoaded(packageName);
});
// XXX glasser and ekate added this filter to strip some undefineds that
// were causing crashes, but maybe the real answer is that there shouldn't
// have been undefineds?
@@ -210,6 +216,13 @@ ConstraintSolver.PackagesResolver.prototype.propagateExactDeps =
check(dependencies, [String]);
check(constraints, [{ packageName: String, version: String, type: String }]);
_.each(dependencies, function (packageName) {
self._ensurePackageInfoLoaded(packageName);
});
_.each(constraints, function (constraint) {
self._ensurePackageInfoLoaded(constraint.packageName);
});
var dc = self._splitDepsToConstraints(dependencies, constraints);
// XXX resolver.resolve can throw an error, should have error handling with