From 08f0a3bab077d2a07ab84ce71229fbfef9e23063 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Mon, 25 Aug 2014 17:25:08 -0700 Subject: [PATCH] Fixes to unforced update to not-quite-last release Make sure that project._ensureDepsUpToDate does not get run mid-update, since it might decide that various things are not compatible with the packages in the current release. When the update command runs the constraint solver explicitly, it passes ignoreProjectDeps, but implicit calls can lead to an unhappy process.exit. --- tools/commands-packages.js | 26 ++++++++++++++++++++++---- tools/project.js | 5 ++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/commands-packages.js b/tools/commands-packages.js index 43d6dab1bc..12fd1e54cb 100644 --- a/tools/commands-packages.js +++ b/tools/commands-packages.js @@ -1270,6 +1270,8 @@ main.registerCommand({ return 1; } + var solutionReleaseRecord = null; + if (!options["packages-only"] && ! files.usesWarehouse()) { process.stderr.write( "You are running Meteor from a checkout, so we cannot update the Meteor release.\n" + @@ -1443,7 +1445,7 @@ main.registerCommand({ var directDependencies = project.getConstraints(); var previousVersions; var messages = buildmessage.capture(function () { - previousVersions = project.getVersions(); + previousVersions = project.getVersions({dontRunConstraintSolver: true}); }); if (messages.hasMessages()) { process.stderr.write(messages.formatMessages()); @@ -1481,11 +1483,14 @@ main.registerCommand({ } return false; } + solutionReleaseRecord = releaseRecord; return true; }); if (!solutionReleaseVersion) { - // XXX put an error here when we stop doing an error on every failure above + process.stdout.write( + "This project is at the latest release which is compatible with your\n" + + "current package constraints.\n"); return 1; } @@ -1544,10 +1549,23 @@ main.registerCommand({ // We can't update packages when we are not in a release. if (!options.appDir) return 0; + var releasePackages = {}; + if (release.current.isProperRelease()) { + if (solutionReleaseRecord) { + // We updated the release (well, possibly a no-op). Use the packages + // from the chosen release. + releasePackages = solutionReleaseRecord.packages; + } else { + // This maybe is --packages-only. Use the packages from the current + // release. + releasePackages = release.current.getPackages(); + } + } + var versions, allPackages; messages = buildmessage.capture(function () { - versions = project.getVersions(); - allPackages = project.getCurrentCombinedConstraints(); + versions = project.getVersions({dontRunConstraintSolver: true}); + allPackages = project.calculateCombinedConstraints(releasePackages); }); if (messages.hasMessages()) { process.stderr.write(messages.formatMessages()); diff --git a/tools/project.js b/tools/project.js index 80bf81f29c..d8f89d6426 100644 --- a/tools/project.js +++ b/tools/project.js @@ -428,8 +428,11 @@ _.extend(Project.prototype, { // versions file. // // Returns an object mapping package name to its string version. - getVersions : function () { + getVersions : function (options) { var self = this; + options = options || {}; + if (options.dontRunConstraintSolver) + return self.dependencies; buildmessage.assertInCapture(); self._ensureDepsUpToDate(); return self.dependencies;