Rollback of commit f6866778db261e5d8b95ee1c46622ceb19a609a4.

*** Reason for rollback ***

Breaks the Jenkins continuous builds. The error message is a mysterious Skyframe one and it only raised if the Android NDK/SDK is set in the WORKSPACE file:

java.lang.IllegalStateException: ANDROID_NDK_REPOSITORY:@androidndk -> GroupedListHelper{groupedList=[FILE:[/usr/local/google/home/lberki/.cache/bazel/_bazel_lberki/97aa07230f44a76bcaa14338f20a8e2e/external/androidndk/ndk/RELEASE.TXT]/[]], elements=[FILE:...], size=24}, reverseDepsToSignal=ReverseDeps{reverseDeps=REPOSITORY:@androidndk, singleReverseDep=true, dataToConsolidate=null}, lastBuildDirectDeps=null, dirtyDirectDepIterator=null}}
	at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:994)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$2.run(AbstractQueueVisitor.java:496)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)



*** Original change description ***

Preserve repositories' rooted paths

This was taking the "right" rooted path, converting it to a path, and then
making the rooted path [/path/to/external/repo/BUILD]/[] (where it should
have been [/path/to/external/repo]/[BUILD]).

--
MOS_MIGRATED_REVID=107768560
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java
index fb166e6..93d3cf6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java
@@ -135,9 +135,6 @@
   protected RepositoryValue symlinkBuildFile(
       Rule rule, Path workspaceDirectory, FileValue directoryValue, Environment env)
       throws RepositoryFunctionException {
-    Preconditions.checkState(
-        directoryValue.realRootedPath().getRelativePath().equals(PathFragment.EMPTY_FRAGMENT));
-
     AggregatingAttributeMapper mapper = AggregatingAttributeMapper.of(rule);
     PathFragment buildFile = new PathFragment(mapper.get("build_file", Type.STRING));
     Path buildFileTarget = workspaceDirectory.getRelative(buildFile);
@@ -170,8 +167,7 @@
           Transience.TRANSIENT);
     }
 
-    RootedPath buildFilePath = RootedPath.toRootedPath(
-        directoryValue.realRootedPath().getRoot(), new PathFragment("BUILD"));
+    Path buildFilePath = directoryValue.realRootedPath().asPath().getRelative("BUILD");
     if (createSymbolicLink(buildFilePath, buildFileTarget, env) == null) {
       return null;
     }
@@ -211,8 +207,8 @@
       throws RepositoryFunctionException {
     try {
       for (Path target : targetDirectory.getDirectoryEntries()) {
-        RootedPath symlinkPath = RootedPath.toRootedPath(
-            repositoryDirectory, new PathFragment(target.getBaseName()));
+        Path symlinkPath =
+            repositoryDirectory.getRelative(target.getBaseName());
         if (createSymbolicLink(symlinkPath, target, env) == null) {
           return false;
         }
@@ -224,23 +220,24 @@
     return true;
   }
 
-  private static FileValue createSymbolicLink(RootedPath from, Path to, Environment env)
+  private static FileValue createSymbolicLink(Path from, Path to, Environment env)
       throws RepositoryFunctionException {
-    Path fromPath = from.asPath();
     try {
       // Remove not-symlinks that are already there.
-      if (fromPath.exists()) {
-        fromPath.delete();
+      if (from.exists()) {
+        from.delete();
       }
-      FileSystemUtils.ensureSymbolicLink(fromPath, to);
+      FileSystemUtils.ensureSymbolicLink(from, to);
     } catch (IOException e) {
       throw new RepositoryFunctionException(
           new IOException(String.format("Error creating symbolic link from %s to %s: %s",
               from, to, e.getMessage())), Transience.TRANSIENT);
     }
 
+    SkyKey outputDirectoryKey = FileValue.key(RootedPath.toRootedPath(
+        from, PathFragment.EMPTY_FRAGMENT));
     try {
-      return (FileValue) env.getValueOrThrow(FileValue.key(from), IOException.class,
+      return (FileValue) env.getValueOrThrow(outputDirectoryKey, IOException.class,
           FileSymlinkException.class, InconsistentFilesystemException.class);
     } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) {
       throw new RepositoryFunctionException(