Skip to content

Commit

Permalink
Remove more unnecessary buildmessage.captures
Browse files Browse the repository at this point in the history
Part of meteor#3003.
  • Loading branch information
glasser committed Nov 5, 2014
1 parent fb4655d commit 5e10867
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 70 deletions.
20 changes: 4 additions & 16 deletions tools/commands-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1753,15 +1753,7 @@ var maybeUpdateRelease = function (options) {
var solutionReleaseRecord = null;
var solutionPackageVersions = null;
var directDependencies = project.getConstraints();
var previousVersions;
var messages = buildmessage.capture(function () {
previousVersions = project.getVersions({dontRunConstraintSolver: true});
});
if (messages.hasMessages()) {
Console.printMessages(messages);
// We couldn't figure out our current versions, so updating is not going to work.
return 1;
}
var previousVersions = project.getVersions({dontRunConstraintSolver: true});

var solutionReleaseVersion = _.find(releaseVersionsToTry, function (versionToTry) {
var releaseRecord = catalog.official.getReleaseVersion(
Expand Down Expand Up @@ -1923,15 +1915,11 @@ main.registerCommand({
// Let's figure out what packages we are currently using. Don't run the
// constraint solver yet, we don't care about reconciling them, just want to
// know what they are for some internal constraint solver heuristics.
var versions, allPackages;
messages = buildmessage.capture(function () {
versions = project.getVersions({dontRunConstraintSolver: true});
var versions = project.getVersions({dontRunConstraintSolver: true});
var allPackages;
doOrDie(function () {
allPackages = project.calculateCombinedConstraints(releasePackages);
});
if (messages.hasMessages()) {
Console.printMessages(messages);
return 1;
}

// If no packages have been specified, then we will send in a request to
// update all direct dependencies. If a specific list of packages has been
Expand Down
41 changes: 17 additions & 24 deletions tools/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1506,25 +1506,19 @@ var runTestAppForPackages = function (testPackages, testRunnerAppDir, options) {
// compute them for us. This means that right now, we are testing all packages
// as they work together.
var tests = [];
var messages = buildmessage.capture(function () {
_.each(testPackages, function(name) {
var versionNames = catalog.complete.getSortedVersions(name);
if (versionNames.length !== 1)
throw Error("local package should have one version?");
var versionRecord = catalog.complete.getVersion(name, versionNames[0]);
if (versionRecord && versionRecord.testName) {
tests.push(versionRecord.testName);
}
});
_.each(testPackages, function(name) {
var versionNames = catalog.complete.getSortedVersions(name);
if (versionNames.length !== 1)
throw Error("local package should have one version?");
var versionRecord = catalog.complete.getVersion(name, versionNames[0]);
if (versionRecord && versionRecord.testName) {
tests.push(versionRecord.testName);
}
});
if (messages.hasMessages()) {
Console.stderr.write(messages.formatMessages());
return 1;
}
project.forceEditPackages(tests, 'add');

// We don't strictly need to do this before we bundle, but can't hurt.
messages = buildmessage.capture({
var messages = buildmessage.capture({
title: 'Getting packages ready'
},function () {
project._ensureDepsUpToDate();
Expand Down Expand Up @@ -1590,8 +1584,8 @@ main.registerCommand({
hidden: true,
catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true })
}, function (options) {
var messages;
var count = 0;
var explicitPackages;
// No packages specified. Rebuild everything.
if (options.args.length === 0) {
if (options.appDir) {
Expand All @@ -1603,19 +1597,18 @@ main.registerCommand({
_.each(programsSubdirs, function (program) {
// The implementation of this part of the function might change once we
// change the control file format to explicitly specify packages and
// programs instead of just loading everything in the programs directory?
// programs instead of just loading everything in the programs
// directory?
files.rm_recursive(path.join(programsDir, program, '.build.' + program));
});
}

messages = buildmessage.capture(function () {
count = catalog.complete.rebuildLocalPackages();
});
} else {
messages = buildmessage.capture(function () {
count = catalog.complete.rebuildLocalPackages(options.args);
});
explicitPackages = options.args;
}

var messages = buildmessage.capture(function () {
count = catalog.complete.rebuildLocalPackages(explicitPackages);
});
if (count)
console.log("Built " + count + " packages.");
if (messages.hasMessages()) {
Expand Down
1 change: 1 addition & 0 deletions tools/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ files.getUniloadDir = function () {
// success or null on failure (in which case buildmessages will be
// emitted).
files.getSettings = function (filename, watchSet) {
buildmessage.assertInCapture();
var absPath = path.resolve(filename);
var buffer = watch.readAndWatchFile(watchSet, absPath);
if (buffer === null) {
Expand Down
21 changes: 6 additions & 15 deletions tools/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,21 +704,12 @@ Fiber(function () {
}


// Initialize the server catalog. Among other things, this is where
// we get release information (used by springboarding). This doesn't
// build anything (except maybe, if running from a checkout, packages
// that we need to uniload, which really ought to build) so it's OK
// to die on errors.
var messages = buildmessage.capture({ title: "Initializing server catalog" }, function () {
catalog.official.initialize({
offline: !!process.env.METEOR_OFFLINE_CATALOG
});
// Initialize the server catalog. Among other things, this is where we get
// release information (used by springboarding). We do not at this point talk
// to the server and refresh it.
catalog.official.initialize({
offline: !!process.env.METEOR_OFFLINE_CATALOG
});
if (messages.hasMessages()) {
Console.error("=> Errors while initializing package catalog:\n");
Console.error(messages.formatMessages());
process.exit(1);
}

// We do NOT initialize catalog.complete yet. When we do that, we will build
// all local packages, and for both performance and correctness reasons, we
Expand Down Expand Up @@ -1259,7 +1250,7 @@ commandName + ": You're not in a Meteor project directory.\n" +
files.getCurrentToolsDir(), 'packages'));
}

var messages = buildmessage.capture({ title: "Initializing catalog" }, function () {
messages = buildmessage.capture({ title: "Initializing catalog" }, function () {
catalog.complete.initialize({
localPackageSearchDirs: localPackageSearchDirs
});
Expand Down
17 changes: 2 additions & 15 deletions tools/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,21 +423,8 @@ _.extend(Project.prototype, {
}
// If we can't find the old version, then maybe that was a local package and
// now is not, and that is also not news.
var oldVersion;
var newRec;
var messages = buildmessage.capture(function () {
oldVersion = catalog.complete.getVersion(package, oldV);
newRec =
catalog.complete.getVersion(package, newV);
});
if (messages.hasMessages()) {
// It would be very weird for us to end up here! But it is
// theoretically possible. If it happens, we should probably not crash
// (since we have already done all the operations) and logging a
// confusing message will just be confusing, so ... recover by
// skipping, I guess.
return;
};
var oldVersion = catalog.complete.getVersion(package, oldV);
var newRec = catalog.complete.getVersion(package, newV);

// The new version has to exist, or we wouldn't have chosen it.
if (!oldVersion) {
Expand Down

0 comments on commit 5e10867

Please sign in to comment.