Potentially address issue 3653

See #3653
This commit is contained in:
David Greenspan
2015-02-09 08:29:11 -08:00
parent c0b0a6e92a
commit e5f73a3636
2 changed files with 20 additions and 2 deletions

View File

@@ -27,13 +27,26 @@ CS.PackagesResolver = function (catalog, options) {
// included versions are the only pre-releases that are allowed to match
// constraints that don't specifically name them during the "try not to
// use unanticipated pre-releases" pass
// - missingPreviousVersionIsError - throw an error if a package version in
// previousSolution is not found in the catalog
CS.PackagesResolver.prototype.resolve = function (dependencies, constraints,
options) {
var self = this;
options = options || {};
var input = new CS.Input(dependencies, constraints, self.catalogCache,
options);
_.pick(options, 'upgrade', 'anticipatedPrereleases',
'previousSolution'));
input.loadFromCatalog(self.catalogLoader);
if (options.previousSolution && options.missingPreviousVersionIsError) {
_.each(options.previousSolution, function (version, package) {
if (! input.catalogCache.hasPackageVersion(package, version)) {
CS.throwConstraintSolverError(
"Package version not in catalog: " + package + " " + version);
}
});
}
return CS.PackagesResolver._resolveWithInput(input, this._options.nudge);
};

View File

@@ -391,6 +391,8 @@ _.extend(ProjectContext.prototype, {
var anticipatedPrereleases = self._getAnticipatedPrereleases(
depsAndConstraints.constraints, cachedVersions);
var isFirstAttempt = true;
// Nothing before this point looked in the official or project catalog!
// However, the resolver does, so it gets run in the retry context.
catalog.runAndRetryWithRefreshIfHelpful(function () {
@@ -399,7 +401,8 @@ _.extend(ProjectContext.prototype, {
var resolveOptions = {
previousSolution: cachedVersions,
anticipatedPrereleases: anticipatedPrereleases
anticipatedPrereleases: anticipatedPrereleases,
missingPreviousVersionIsError: isFirstAttempt
};
if (self._upgradePackageNames)
resolveOptions.upgrade = self._upgradePackageNames;
@@ -432,6 +435,8 @@ _.extend(ProjectContext.prototype, {
self._completedStage = STAGE.RESOLVE_CONSTRAINTS;
});
isFirstAttempt = false;
});
},