From 831967dd605dca40f06f23adedafa89d2c7ef08d Mon Sep 17 00:00:00 2001 From: ekatek Date: Wed, 28 May 2014 16:10:29 -0700 Subject: [PATCH] cleanup of merge --- tools/catalog.js | 48 +++++++++++++++++++++++++++++++++++++++++++++-- tools/commands.js | 2 -- tools/project.js | 1 - tools/utils.js | 3 ++- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/tools/catalog.js b/tools/catalog.js index 31df68ca5f..32d77222b1 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -14,6 +14,8 @@ var watch = require('./watch.js'); var files = require('./files.js'); var utils = require('./utils.js'); var baseCatalog = require('./catalog-base.js').BaseCatalog; +var files = require('./files.js'); +var fiberHelpers = require('./fiber-helpers.js'); var catalog = exports; @@ -53,11 +55,54 @@ _.extend(ServerCatalog.prototype, { // The server catalog is always initialized. self.initialized = true; + + // This is set to an array while refresh() is running; if another refresh() + // call happens during a yield, instead of doing a second refresh it just + // waits for the first to finish. + self._refreshFutures = null; + + }, + + // Refresh the packages in the catalog. Print a warning if we cannot connect + // to the package server. + // + // If a refresh is already in progress (which is yielding), it just waits for + // the in-progress refresh to finish. + refresh: function () { + var self = this; + self._requireInitialized(); + + if (self._refreshFutures) { + var f = new Future; + self._refreshFutures.push(f); + f.wait(); + return; + } + + self._refreshFutures = []; + + var thrownError = null; + try { + self._refresh(); + } catch (e) { + thrownError = e; + } + + while (self._refreshFutures.length) { + var fut = self._refreshFutures.pop(); + if (thrownError) { + // XXX is it really right to throw the same error multiple times? + fut.throw(thrownError); + } else { + fut.return(); + } + } + self._refreshFutures = null; }, // Refresh the packages in the catalog. Prints a warning if we cannot connect // to the package server, and intend to. - refresh: function () { + _refresh: function () { var self = this; var localData = packageClient.loadCachedServerData(); @@ -232,7 +277,6 @@ _.extend(CompleteCatalog.prototype, { // 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.rootDir) { - console.log("ignore project deps & resolve"); return self.resolver.resolve(deps, constr, resolverOpts); } diff --git a/tools/commands.js b/tools/commands.js index c3e9e5b5bf..4717e4ec8f 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -511,7 +511,6 @@ main.registerCommand({ // OK, let's figure out what release fits with our package constraints! -<<<<<<< HEAD // XXX this will actually be a loop over possible releases in the non-force // case // XXX better error checking on name @@ -542,7 +541,6 @@ main.registerCommand({ // XXX did we have to change some package versions? we should probably // mention that fact. // XXX error handling. -======= var releaseVersionsToTry; if (release.forced) { releaseVersionsToTry = [release.current.getReleaseVersion()]; diff --git a/tools/project.js b/tools/project.js index 4d4edad665..dbc9f8e666 100644 --- a/tools/project.js +++ b/tools/project.js @@ -100,7 +100,6 @@ var Project = function () { self._depsUpToDate = false; }; -<<<<<<< HEAD _.extend(Project.prototype, { // Set a given root directory as the project's root directory. Figure out all // relevant file paths and read in data that is independent of the constraint diff --git a/tools/utils.js b/tools/utils.js index f25bb6ab05..5f24d57f32 100644 --- a/tools/utils.js +++ b/tools/utils.js @@ -70,7 +70,7 @@ exports.getHost = function () { if (output) { ret = output.trim(); } - } + }; if (archinfo.matches(archinfo.host(), 'os.osx')) { // On OSX, to get the human-readable hostname that the user chose, @@ -273,6 +273,7 @@ exports.isDirectory = function (dir) { return false; } return stats.isDirectory(); +}; // XXX from Underscore.String (http://epeli.github.com/underscore.string/) exports.startsWith = function(str, starts) {