From e1572801d5910ebfb88eaccc4831cb9e0c77eebf Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 18 Nov 2014 18:30:45 -0800 Subject: [PATCH] Revert "releaseFile.setRelease should be in-memory only" This reverts commit 3735ff62d51af6c7e537d5c3fe35e79cebb68735. --- tools/commands.js | 9 ++--- tools/project-context.js | 85 ++++++++-------------------------------- 2 files changed, 20 insertions(+), 74 deletions(-) diff --git a/tools/commands.js b/tools/commands.js index 9cd2bde6ec..5c261e1a6b 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -575,9 +575,7 @@ main.registerCommand({ if (buildmessage.jobHasMessages()) return; - // Overwrite .meteor/release. (Will not be written to disk until the end of - // prepareProjectForBuild.) - projectContext.releaseFile.setRelease( + projectContext.releaseFile.write( release.current.isCheckout() ? "none" : release.current.name); if (buildmessage.jobHasMessages()) return; @@ -1345,9 +1343,8 @@ main.registerCommand({ projectContext.initializeCatalog(); }); - // Overwrite .meteor/release. (Will not be written to disk until the end of - // prepareProjectForBuild.) - projectContext.releaseFile.setRelease( + // Overwrite .meteor/release. + projectContext.releaseFile.write( release.current.isCheckout() ? "none" : release.current.name); var packagesToAdd = getTestPackageNames(projectContext, options.args); diff --git a/tools/project-context.js b/tools/project-context.js index b4dc4314a1..3f0e09d0fb 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -368,7 +368,7 @@ _.extend(exports.ProjectContext.prototype, { self._addAppConstraints(depsAndConstraints); self._addLocalPackageConstraints(depsAndConstraints); - self._addReleaseConstraints(depsAndConstraints); + // XXX #3006 Add constraints from the release // XXX #3006 Add constraints from other programs, if we reimplement that. // XXX #3006 Add a dependency on ctl return depsAndConstraints; @@ -397,19 +397,6 @@ _.extend(exports.ProjectContext.prototype, { }); }, - _addReleaseConstraints: function (depsAndConstraints) { - var self = this; - - _.each(self.localCatalog.getAllPackageNames(), function (packageName) { - var versionRecord = self.localCatalog.getLatestVersion(packageName); - var constraint = - utils.parseConstraint(packageName + "@=" + versionRecord.version); - // Add a constraint ("this is the only version available") but no - // dependency (we don't automatically use all local packages!) - depsAndConstraints.constraints.push(constraint); - }); - }, - _buildResolver: function () { var self = this; @@ -460,9 +447,6 @@ _.extend(exports.ProjectContext.prototype, { _saveChangedMetadata: function () { var self = this; - // Save any changes to .meteor/release. - self.releaseFile.writeIfModified(); - // Save any changes to .meteor/packages. self.projectConstraintsFile.writeIfModified(); @@ -921,30 +905,22 @@ exports.ReleaseFile = function (options) { var self = this; self.filename = path.join(options.projectDir, '.meteor', 'release'); - self._reset(); + self.watchSet = null; + // The release name actually written in the file. Null if no fill. Empty if + // the file is empty. + self.unnormalizedReleaseName = null; + // The full release name (with METEOR@ if it's missing in + // unnormalizedReleaseName). + self.fullReleaseName = null; + // FOO@bar unless FOO === "METEOR" in which case "Meteor bar". + self.displayReleaseName = null; + // Just the track. + self.releaseTrack = null; + self.releaseVersion = null; self._readFile(); }; _.extend(exports.ReleaseFile.prototype, { - _reset: function () { - var self = this; - self.watchSet = null; - self._modified = false; - - // The release name actually written in the file. Null if no fill. Empty - // if the file is empty. - self.unnormalizedReleaseName = null; - // The full release name (with METEOR@ if it's missing in - // unnormalizedReleaseName). - self.fullReleaseName = null; - // FOO@bar unless FOO === "METEOR" in which case "Meteor bar". - self.displayReleaseName = null; - // Just the track. - self.releaseTrack = null; - // Just the version. - self.releaseVersion = null; - }, - fileMissing: function () { var self = this; return self.unnormalizedReleaseName === null; @@ -963,16 +939,9 @@ _.extend(exports.ReleaseFile.prototype, { || self.isCheckout()); }, - getReleaseCatalogRecord: function () { - var self = this; - return catalog.official.getReleaseVersion( - self.releaseTrack, self.releaseVersion); - }, - _readFile: function () { var self = this; - self._reset(); // Start a new watchSet, in case we just overwrote this. self.watchSet = new watch.WatchSet; var contents = watch.readAndWatchFile(self.watchSet, self.filename); @@ -984,17 +953,12 @@ _.extend(exports.ReleaseFile.prototype, { var lines = _.compact(_.map(files.splitBufferToLines(contents), files.trimSpaceAndComments)); // noReleaseSpecified will be true. - if (! lines.length) { + if (!lines.length) { self.unnormalizedReleaseName = ''; return; } - self._setRelease(lines[0]); - }, - - _setRelease: function (releaseName) { - var self = this; - self.unnormalizedReleaseName = releaseName; + self.unnormalizedReleaseName = lines[0]; var parts = utils.splitReleaseName(self.unnormalizedReleaseName); self.fullReleaseName = parts[0] + '@' + parts[1]; self.displayReleaseName = utils.displayRelease(parts[0], parts[1]); @@ -1002,24 +966,9 @@ _.extend(exports.ReleaseFile.prototype, { self.releaseVersion = parts[1]; }, - // Sets the release string (in any format that we can parse) in-memory; will - // be written by writeIfModified which is called by the saveChangedMetadata - // stage of project preparation. - setRelease: function (releaseName) { + write: function (releaseName) { var self = this; - self._setRelease(releaseName); - self._modified = true; - }, - - writeIfModified: function () { - var self = this; - self._modified && self._write(); - }, - - _write: function (releaseName) { - var self = this; - files.writeFileAtomically(self.filename, - self.unnormalizedReleaseName + '\n'); + files.writeFileAtomically(self.filename, releaseName + '\n'); self._readFile(); } });