diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
index ea4c7889302de2..7d6fd6f920ffad 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
@@ -27,6 +27,7 @@
import com.google.devtools.build.lib.actions.extra.ExtraActionInfo;
import com.google.devtools.build.lib.analysis.platform.PlatformInfo;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.cmdline.RepositoryMapping;
import com.google.devtools.build.lib.collect.nestedset.Depset;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -363,18 +364,36 @@ public boolean showsOutputUnconditionally() {
@Nullable
@Override
public final String getProgressMessage() {
+ return getProgressMessageChecked(null);
+ }
+
+ @Nullable
+ @Override
+ public final String getProgressMessage(RepositoryMapping mainRepositoryMapping) {
+ Preconditions.checkNotNull(mainRepositoryMapping);
+ return getProgressMessageChecked(mainRepositoryMapping);
+ }
+
+ private String getProgressMessageChecked(@Nullable RepositoryMapping mainRepositoryMapping) {
String message = getRawProgressMessage();
if (message == null) {
return null;
}
- message = replaceProgressMessagePlaceholders(message);
+ message = replaceProgressMessagePlaceholders(message, mainRepositoryMapping);
String additionalInfo = getOwner().getAdditionalProgressInfo();
return additionalInfo == null ? message : message + " [" + additionalInfo + "]";
}
- private String replaceProgressMessagePlaceholders(String progressMessage) {
+ private String replaceProgressMessagePlaceholders(String progressMessage,
+ @Nullable RepositoryMapping mainRepositoryMapping) {
if (progressMessage.contains("%{label}") && getOwner().getLabel() != null) {
- progressMessage = progressMessage.replace("%{label}", getOwner().getLabel().toString());
+ String labelString;
+ if (mainRepositoryMapping != null) {
+ labelString = getOwner().getLabel().getDisplayForm(mainRepositoryMapping);
+ } else {
+ labelString = getOwner().getLabel().toString();
+ }
+ progressMessage = progressMessage.replace("%{label}", labelString);
}
if (progressMessage.contains("%{output}") && getPrimaryOutput() != null) {
progressMessage =
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionMetadata.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionMetadata.java
index 338fb06993fdbc..0b98b2c7274a47 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionMetadata.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionMetadata.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.actions;
+import com.google.devtools.build.lib.cmdline.RepositoryMapping;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import javax.annotation.Nullable;
@@ -33,6 +34,19 @@ public interface ActionExecutionMetadata extends ActionAnalysisMetadata {
@Nullable
String getProgressMessage();
+ /**
+ * A variant of {@link #getProgressMessage} that additionally takes the {@link RepositoryMapping}
+ * of the main repository, which can be used by the implementation to emit labels with apparent
+ * instead of canonical repository names. A return value of {@code null} indicates no
+ * message should be reported.
+ *
+ *
The default implementation simply returns the result of {@link #getProgressMessage}.
+ */
+ @Nullable
+ default String getProgressMessage(RepositoryMapping mainRepositoryMapping) {
+ return getProgressMessage();
+ }
+
/**
* Returns a human-readable description of the inputs to {@link #getKey(ActionKeyContext)}. Used
* in the output from '--explain', and in error messages for '--check_up_to_date' and
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseCompleteEvent.java
index aad9f721f1ba05..f40f7a2ceb5aae 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseCompleteEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseCompleteEvent.java
@@ -16,6 +16,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.cmdline.RepositoryMapping;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
/**
@@ -24,6 +25,7 @@
public final class LoadingPhaseCompleteEvent implements ExtendedEventHandler.Postable {
private final ImmutableSet