From f02314f66ed3a5184399360fc77ce3fab2e6441a Mon Sep 17 00:00:00 2001 From: ekatek Date: Wed, 10 Sep 2014 15:53:13 -0700 Subject: [PATCH] glasser's responses on the -rc changes --- .../constraint-solver/constraint-solver.js | 6 +++++- packages/constraint-solver/resolver.js | 10 +++++---- tools/catalog.js | 21 +++++++++++++++++-- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/constraint-solver/constraint-solver.js b/packages/constraint-solver/constraint-solver.js index 8b39610d51..2e5dcfda60 100644 --- a/packages/constraint-solver/constraint-solver.js +++ b/packages/constraint-solver/constraint-solver.js @@ -265,8 +265,12 @@ ConstraintSolver.PackagesResolver.prototype.resolve = function ( throw e; } } + var ret = { + answer: resolverResultToPackageMap(res), + usedRCs: resolverOptions["useRCs"] + }; - return resolverResultToPackageMap(res); + return ret; }; var removeUnibuild = function (unitName) { diff --git a/packages/constraint-solver/resolver.js b/packages/constraint-solver/resolver.js index 80431d0486..3b201680eb 100644 --- a/packages/constraint-solver/resolver.js +++ b/packages/constraint-solver/resolver.js @@ -390,7 +390,8 @@ ConstraintSolver.Constraint.prototype.isSatisfied = function ( } if (self.type === "any-reasonable") { - // Non-prerelease versions are always reasonable. + // Non-prerelease versions are always reasonable, and if we are OK with + // using RCs all the time, then they are reasonable too. if (!/-/.test(candidateUV.version) || resolveContext.useRCsOK) return true; @@ -421,9 +422,10 @@ ConstraintSolver.Constraint.prototype.isSatisfied = function ( return self.version === candidateUV.version; } - // If you're not asking for a pre-release, you'll only get it if it was a top - // level explicit mention (eg, in the release). - if (/-/.test(candidateUV.version)) { + // If you're not asking for a pre-release (and you are not in pre-releases-OK + // mode), you'll only get it if it was a top level explicit mention (eg, in + // the release). + if (/-/.test(candidateUV.version) && !resolveContext.useRCsOK) { if (self.version === candidateUV.version) return true; if (!_.has(resolveContext.topLevelPrereleases, self.name) || diff --git a/tools/catalog.js b/tools/catalog.js index cb289db567..251816cf9c 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -528,13 +528,15 @@ _.extend(CompleteCatalog.prototype, { messageAfterMs: 1000, message: "Figuring out the best package versions to use. This may take a moment." }); + + var ret; try { // Then, call the constraint solver, to get the valid transitive subset of // those versions to record for our solution. (We don't just return the // original version lock because we want to record the correct transitive // dependencies) try { - return self.resolver.resolve(deps, constr, resolverOpts); + ret = self.resolver.resolve(deps, constr, resolverOpts); } catch (e) { // Maybe we only failed because we need to refresh. Try to refresh // (unless we already are) and retry. @@ -544,12 +546,27 @@ _.extend(CompleteCatalog.prototype, { } catalog.official.refresh(); self.resolver || self._initializeResolver(); - return self.resolver.resolve(deps, constr, resolverOpts); + ret = self.resolver.resolve(deps, constr, resolverOpts); } } finally { patience.stop(); } + if (ret["usedRCs"]) { + process.stderr.write( +"\nWARNING: In order to resolve constraints, we had to use the following "+ + "experimental package versions:\n"); + var packages = ""; + _.each(ret.answer, function(version, package) { + if (version.split('-').length > 1) { + packages+= package + "@" + version + ", "; + } + }); + packages = packages.slice(0, packages.length - 2); + process.stderr.write(packages + "\n\n"); + } + return ret.answer; }, + // Refresh the packages in the catalog. // // Reread server data from data.json on disk, then load local overrides on top