aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Han-Wen Nienhuys <hanwen@google.com>2015-07-31 10:45:53 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-08-04 09:06:00 +0000
commit35a460556ead2bf0b00300da8ce94c7901b31fd4 (patch)
tree83a04badc69e3a362474adbba064dde11ae54ce3 /src/main/java/com
parente5cf8a9df0dce674314c5a93aecb6c22ba607612 (diff)
*** Reason for rollback *** Query performance regression. -- MOS_MIGRATED_REVID=99560234
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/Reporter.java35
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java17
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/Command.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java4
6 files changed, 5 insertions, 58 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/events/Reporter.java b/src/main/java/com/google/devtools/build/lib/events/Reporter.java
index a3cf6cce86..e0c39250ba 100644
--- a/src/main/java/com/google/devtools/build/lib/events/Reporter.java
+++ b/src/main/java/com/google/devtools/build/lib/events/Reporter.java
@@ -25,7 +25,7 @@ import java.util.List;
* is not intended as a logging mechanism for developer-only messages; use a
* Logger for that.
*
- * <p>The reporter instance is consumed by the build system, and passes events to
+ * The reporter instance is consumed by the build system, and passes events to
* {@link EventHandler} instances. These handlers are registered via {@link
* #addHandler(EventHandler)}.
*
@@ -42,9 +42,6 @@ public final class Reporter implements EventHandler, ExceptionListener {
*/
private final OutErr outErrToReporter = outErrForReporter(this);
private volatile OutputFilter outputFilter = OutputFilter.OUTPUT_EVERYTHING;
- private EventHandler ansiAllowingHandler;
- private EventHandler ansiStrippingHandler;
- private boolean ansiAllowingHandlerRegistered;
public Reporter() {}
@@ -146,34 +143,4 @@ public final class Reporter implements EventHandler, ExceptionListener {
public void setOutputFilter(OutputFilter outputFilter) {
this.outputFilter = outputFilter;
}
-
- /**
- * Registers an ANSI-control-code-allowing EventHandler with an ANSI-stripping EventHandler
- * that is already registered with the reporter. The ANSI-stripping handler can then be replaced
- * with the ANSI-allowing handler by calling {@code #switchToAnsiAllowingHandler} which
- * calls {@code removeHandler} for the ANSI-stripping handler and then {@code addHandler} for the
- * ANSI-allowing handler.
- */
- public synchronized void registerAnsiAllowingHandler(
- EventHandler ansiStrippingHandler,
- EventHandler ansiAllowingHandler) {
- this.ansiAllowingHandler = ansiAllowingHandler;
- this.ansiStrippingHandler = ansiStrippingHandler;
- ansiAllowingHandlerRegistered = true;
- }
-
- /**
- * Restores the ANSI-allowing EventHandler registered using
- * {@code #registerAnsiAllowingHandler(...)}.
- */
- public synchronized void switchToAnsiAllowingHandler() {
- if (ansiAllowingHandlerRegistered) {
- removeHandler(ansiStrippingHandler);
- addHandler(ansiAllowingHandler);
- ansiStrippingHandler = null;
- ansiAllowingHandler = null;
- ansiAllowingHandlerRegistered = false;
- }
- }
-
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
index e73f8c4a79..4d7e9aefe8 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
@@ -362,14 +362,13 @@ public class BlazeCommandDispatcher {
// Setup log filtering
BlazeCommandEventHandler.Options eventHandlerOptions =
optionsParser.getOptions(BlazeCommandEventHandler.Options.class);
- OutErr colorfulOutErr = outErr;
if (!eventHandlerOptions.useColor()) {
- outErr = ansiStripOut(ansiStripErr(outErr));
if (!commandAnnotation.binaryStdOut()) {
- colorfulOutErr = ansiStripOut(colorfulOutErr);
+ outErr = ansiStripOut(outErr);
}
+
if (!commandAnnotation.binaryStdErr()) {
- colorfulOutErr = ansiStripErr(colorfulOutErr);
+ outErr = ansiStripErr(outErr);
}
}
@@ -385,16 +384,6 @@ public class BlazeCommandDispatcher {
EventHandler handler = createEventHandler(outErr, eventHandlerOptions);
Reporter reporter = runtime.getReporter();
reporter.addHandler(handler);
-
- // We register an ANSI-allowing handler associated with {@code handler} so that ANSI control
- // codes can be re-introduced later even if blaze is invoked with --color=no. This is useful
- // for commands such as 'blaze run' where the output of the final executable shouldn't be
- // modified.
- if (!eventHandlerOptions.useColor()) {
- EventHandler ansiAllowingHandler = createEventHandler(colorfulOutErr, eventHandlerOptions);
- reporter.registerAnsiAllowingHandler(handler, ansiAllowingHandler);
- }
-
try {
// While a Blaze command is active, direct all errors to the client's
// event handler (and out/err streams).
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/Command.java b/src/main/java/com/google/devtools/build/lib/runtime/Command.java
index c030a1d558..318e3e419b 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/Command.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/Command.java
@@ -75,16 +75,12 @@ public @interface Command {
/**
* Returns true if this command wants to write binary data to stdout.
* Enabling this flag will disable ANSI escape stripping for this command.
- * This should be used in conjunction with {@code Reporter#switchToAnsiAllowingHandler}.
- * See {@link RunCommand} for example usage.
*/
boolean binaryStdOut() default false;
/**
* Returns true if this command wants to write binary data to stderr.
* Enabling this flag will disable ANSI escape stripping for this command.
- * This should be used in conjunction with {@code Reporter#switchToAnsiAllowingHandler}.
- * See {@link RunCommand} for example usage.
*/
boolean binaryStdErr() default false;
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
index d1f18cefcd..2448d90aca 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
@@ -181,8 +181,8 @@ public class InfoCommand implements BlazeCommand {
@Override
public ExitCode exec(final BlazeRuntime runtime, final OptionsProvider optionsProvider) {
- runtime.getReporter().switchToAnsiAllowingHandler();
Options infoOptions = optionsProvider.getOptions(Options.class);
+
OutErr outErr = runtime.getReporter().getOutErr();
// Creating a BuildConfiguration is expensive and often unnecessary. Delay the creation until
// it is needed.
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java
index 04e2b047c3..ecc487534b 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java
@@ -136,7 +136,6 @@ public final class QueryCommand implements BlazeCommand {
return ExitCode.ANALYSIS_FAILURE;
}
- runtime.getReporter().switchToAnsiAllowingHandler();
// 3. Output results:
PrintStream output = new PrintStream(runtime.getReporter().getOutErr().getOutputStream());
try {
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
index 16ed00abe9..715ef0e385 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
@@ -305,10 +305,6 @@ public class RunCommand implements BlazeCommand {
.addArgs(cmdLine).setEnv(runtime.getClientEnv()).setWorkingDir(workingDir).build();
try {
- // Restore a raw EventHandler if it is registered. This allows for blaze run to produce the
- // actual output of the command being run even if --color=no is specified.
- runtime.getReporter().switchToAnsiAllowingHandler();
-
// The command API is a little strange in that the following statement
// will return normally only if the program exits with exit code 0.
// If it ends with any other code, we have to catch BadExitStatusException.