diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java b/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java index 174f8767fb7b78..b1e6b52a09eba9 100644 --- a/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java +++ b/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java @@ -199,13 +199,17 @@ public RepositoryName getOwnerRepoIfNotVisible() { return ownerRepoIfNotVisible; } - /** Returns if this is the main repository, that is, {@link #getName} is empty. */ + /** Returns if this is the main repository. */ public boolean isMain() { - return name.isEmpty(); + return equals(MAIN); } /** Returns the repository name, with leading "{@literal @}". */ public String getNameWithAt() { + if (!isVisible()) { + return String.format( + "@[unknown repo '%s' requested from %s]", name, ownerRepoIfNotVisible.getNameWithAt()); + } return '@' + name; } diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java index 986f172a58b1c9..93edaa1d603b25 100644 --- a/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java +++ b/src/main/java/com/google/devtools/build/lib/cmdline/TargetPattern.java @@ -921,8 +921,8 @@ public TargetPattern parse(String pattern) throws TargetParsingException { if (!repository.isVisible()) { throw new TargetParsingException( String.format( - "Repository '%s' is not visible from repository '@%s'", - repository.getNameWithAt(), repository.getOwnerRepoIfNotVisible()), + "Repository '@%s' is not visible from repository '@%s'", + repository.getName(), repository.getOwnerRepoIfNotVisible()), Code.PACKAGE_NOT_FOUND); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java index 976e1f3cdb6c60..77a52d36833f73 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java @@ -245,9 +245,8 @@ public SkyValue compute(SkyKey skyKey, Environment env) if (!repositoryName.isVisible()) { return new NoRepositoryDirectoryValue( String.format( - "Repository '%s' is not visible from repository '%s'", - repositoryName.getNameWithAt(), - repositoryName.getOwnerRepoIfNotVisible().getNameWithAt())); + "Repository '@%s' is not visible from repository '%s'", + repositoryName.getName(), repositoryName.getOwnerRepoIfNotVisible().getNameWithAt())); } Map overrides = REPOSITORY_OVERRIDES.get(env); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java index 79d88166e77269..3338d330d60f68 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java @@ -102,8 +102,8 @@ public SkyValue compute(SkyKey skyKey, Environment env) return new PackageLookupValue.NoRepositoryPackageLookupValue( repoName.getNameWithAt(), String.format( - "Repository '%s' is not visible from repository '%s'", - repoName.getNameWithAt(), repoName.getOwnerRepoIfNotVisible().getNameWithAt())); + "Repository '@%s' is not visible from repository '%s'", + repoName.getName(), repoName.getOwnerRepoIfNotVisible().getNameWithAt())); } if (deletedPackages.get().contains(packageKey)) {