From e921b20caa0629bbc4e6d4c97f8be5fb3000df8c Mon Sep 17 00:00:00 2001 From: David Glasser Date: Thu, 13 Nov 2014 00:14:08 -0800 Subject: [PATCH] Remove catalog.resolveConstraints Also remove the subclass of LocalCatalog used for the isopacket building catalog... it can just use LocalCatalog and set a flag (which is only checked in one place). --- tools/catalog-bootstrap-checkout.js | 60 ----------------- tools/catalog.js | 100 ---------------------------- tools/commands-packages.js | 3 + tools/isopackets.js | 5 +- tools/project-context.js | 3 +- tools/project.js | 1 + 6 files changed, 9 insertions(+), 163 deletions(-) delete mode 100644 tools/catalog-bootstrap-checkout.js diff --git a/tools/catalog-bootstrap-checkout.js b/tools/catalog-bootstrap-checkout.js deleted file mode 100644 index b8b8ce2fbc..0000000000 --- a/tools/catalog-bootstrap-checkout.js +++ /dev/null @@ -1,60 +0,0 @@ -var _ = require('underscore'); -var util = require('util'); -var fs = require('fs'); -var buildmessage = require('./buildmessage.js'); -var LocalCatalog = require('./catalog-local.js').LocalCatalog; -var tropohouse = require('./tropohouse.js'); - -// BootstrapCatalogCheckout represents a catalog of the packages at bootstrap -// when we are running in checkout mode. -// This catalog is typically never used directly by the user. -// An instance of this catalog is created in catalog.js -var BootstrapCatalogCheckout = function () { - var self = this; - LocalCatalog.call(this); - self.isopacketBuildingCatalog = true; -}; - -util.inherits(BootstrapCatalogCheckout, LocalCatalog); - -_.extend(BootstrapCatalogCheckout.prototype, { - resolveConstraints: function (constraints, resolverOpts, opts) { - var self = this; - opts = opts || {}; - self._requireInitialized(); - buildmessage.assertInCapture(); - - // Building isopackets should always ignore the project: it's essentially - // loading part of the tool, which shouldn't be affected by your app's - // dependencies. - if (!opts.ignoreProjectDeps) - throw Error("whoa, if for isopackets, why not ignoring project?"); - - // OK, we're building part of an isopacket. - var ret = {}; - _.each(constraints, function (constraint) { - if (_.has(constraint, 'version')) { - if (constraint.version !== null) { - throw Error("isopacket specifying version? " + JSON.stringify(constraint)); - } - delete constraint.version; - } - - // Constraints for isopackets should just be packages with no version - // constraint and one local version (since they should all be in core). - if (!_.has(constraint, 'name') || - constraint.constraints.length > 1 || - constraint.constraints[0].type !== 'any-reasonable') { - throw Error("Surprising constraint: " + JSON.stringify(constraint)); - } - if (!_.has(self.packages, constraint.name)) { - throw Error("Trying to resolve unknown package: " + constraint.name); - } - ret[constraint.name] = - self.packages[constraint.name].versionRecord.version; - }); - return ret; - } -}); - -exports.BootstrapCatalogCheckout = BootstrapCatalogCheckout; diff --git a/tools/catalog.js b/tools/catalog.js index 780020f936..ff12bd281a 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -214,106 +214,6 @@ _.extend(LayeredCatalog.prototype, { return self.getVersion(name, latest); }, - resolveConstraints: function (constraints, resolverOpts, opts) { - var self = this; - opts = opts || {}; - // OK, since we are the complete catalog, isopackets must be fully - // initialized, so it's safe to load a resolver if we didn't - // already. (Putting this off until the first call to resolveConstraints - // also helps with performance: no need to build this package and load the - // large mori module unless we actually need it.) - self.resolver = self.resolver || self._buildResolver(); - - // Looks like we are not going to be able to avoid calling the constraint - // solver, so let's process the input (constraints) into the correct - // arguments to the constraint solver. - // - // -deps: list of package names that we depend on - // -constr: constraints of the proper form from parseConstraint in utils.js - // - // Weak dependencies are constraints (they constrain the result), but not - // dependencies. - var deps = []; - var constr = []; - _.each(constraints, function (constraint) { - constraint = _.clone(constraint); - if (!constraint.weak) { - deps.push(constraint.name); - } - delete constraint.weak; - constr.push(constraint); - }); - - // If we are called with 'ignore projectDeps', then we don't even look to - // see what the project thinks and recalculate everything. Similarly, if the - // project root path has not been initialized, we are probably running - // outside of a project, and have nothing to look at for guidance. - if (!opts.ignoreProjectDeps && project.project && - project.project.viableDepSource) { - // Anything in the project's dependencies was calculated based on a - // previous constraint solver run, and needs to be taken as absolute truth - // for now: we can't use any packages that are of different versions from - // what we've already decided from the project! - _.each(project.project.getVersions(), function (version, name) { - constr.push(utils.parseConstraint(name + "@=" + version)); - }); - } - - // Local packages can only be loaded from the version we have the source - // for: that's a weak exact constraint. - _.each(self.packageSources, function (packageSource, name) { - constr.push(utils.parseConstraint(name + "@=" + packageSource.version)); - }); - - var ret = buildmessage.enterJob({ - title: "Selecting package versions" }, - function () { - // 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) - return self.resolver.resolve(deps, constr, resolverOpts); - }); - if (ret["usedRCs"]) { - var expPackages = []; - _.each(ret.answer, function(version, package) { - if (self.isLocalPackage(package)) - return; - if (version.split('-').length > 1) { - if (!(resolverOpts.previousSolution && - resolverOpts.previousSolution[package] === version)) { - var oldConstraints = _.where(constr, { name: package } ); - var printMe = true; - _.each(oldConstraints, function (oC) { - _.each(oC.constraints, function (specOC) { - if (specOC.version === version) { - printMe = false; - } - }); - }); - if (printMe) { - expPackages.push({ - name: " " + package + "@" + version, - description: self.getVersion(package, version).description - }); - }; - }} - }); - if (!_.isEmpty(expPackages)) { - // XXX: Couldn't figure out how to word this better for better tenses. - // - // XXX: this shouldn't be here. This is library code... it - // shouldn't be printing. - // https://github.com/meteor/meteor/wiki/Meteor-Style-Guide#only-user-interface-code-should-engage-with-the-user - Console.info( - "\nIn order to resolve constraints, we had to use the following\n"+ - "experimental package versions:"); - utils.printPackageList(expPackages); - } - } - return ret.answer; - }, - // Refresh the catalogs referenced by this catalog. // options: // - watchSet: if provided, any files read in reloading packages will be added diff --git a/tools/commands-packages.js b/tools/commands-packages.js index 7e4cc9c60d..b812979117 100644 --- a/tools/commands-packages.js +++ b/tools/commands-packages.js @@ -1774,6 +1774,7 @@ var maybeUpdateRelease = function (options) { }); try { var messages = buildmessage.capture(function () { + // XXX #3006 no longer exists solutionPackageVersions = catalog.complete.resolveConstraints( constraints, { previousSolution: previousVersions }, @@ -1949,6 +1950,7 @@ main.registerCommand({ // any constraints that we didn't have before. var newVersions; var messages = buildmessage.capture(function () { + // XXX #3006 no longer exists newVersions = catalog.complete.resolveConstraints(allPackages, { previousSolution: versions, upgrade: upgradePackages @@ -2199,6 +2201,7 @@ main.registerCommand({ versions = project.getVersions(); // Call the constraint solver. + // XXX #3006 no longer exists newVersions = catalog.complete.resolveConstraints( allPackages, { previousSolution: versions }, diff --git a/tools/isopackets.js b/tools/isopackets.js index ce73c0c15c..6689fad4b8 100644 --- a/tools/isopackets.js +++ b/tools/isopackets.js @@ -215,8 +215,9 @@ var newIsopacketBuildingCatalog = function () { // XXX #3006 once a lot more refactors are done, this should be able to just // be a LocalCatalog. There's no reason that resolveConstraints should be // called here! - var catalogBootstrapCheckout = require('./catalog-bootstrap-checkout.js'); - var isopacketCatalog = new catalogBootstrapCheckout.BootstrapCatalogCheckout; + var catalogLocal = require('./catalog-local.js'); + var isopacketCatalog = new catalogLocal.LocalCatalog; + isopacketCatalog.isopacketBuildingCatalog = true; var messages = buildmessage.capture( { title: "Scanning local core packages" }, function () { diff --git a/tools/project-context.js b/tools/project-context.js index 5bc6055225..54ab7765a7 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -171,7 +171,8 @@ _.extend(exports.ProjectContext.prototype, { if (!solution) return; // error is already in buildmessage - // XXX #3006 Check solution.usedRCs and maybe print something about it + // XXX #3006 Check solution.usedRCs and maybe print something about it. This + // code used to exist in catalog.js. self.packageMap = new packageMapModule.PackageMap(solution.answer, cat); }, diff --git a/tools/project.js b/tools/project.js index 12920c9ece..d2fca43499 100644 --- a/tools/project.js +++ b/tools/project.js @@ -224,6 +224,7 @@ _.extend(Project.prototype, { // solution. It is useful to set ignoreProjectDeps, but not nessessary, // since self.viableDepSource is false. try { + // XXX #3006 no longer exists var newVersions = catalog.complete.resolveConstraints( self.combinedConstraints, { previousSolution: self.dependencies },