Rename relativePath -> rootRelativePath in Root and friends.

This makes it clearer that the path fragments in question are relative *to the root*. Confusingly, when the root is absolute, the root relative fragment is also absolute. This makes it a tiny bit clearer that the path fragment may be absolute.

PiperOrigin-RevId: 182544893
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
index 9cae797..dc04d4b 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java
@@ -55,7 +55,7 @@
     RootedPath rootedPath = (RootedPath) skyKey.argument();
     RootedPath realRootedPath = null;
     FileStateValue realFileStateValue = null;
-    PathFragment relativePath = rootedPath.getRelativePath();
+    PathFragment relativePath = rootedPath.getRootRelativePath();
 
     // Resolve ancestor symlinks, but only if the current file is not the filesystem root (has no
     // parent) or a package path root (treated opaquely and handled by skyframe's DiffAwareness
@@ -117,7 +117,7 @@
   private static Pair<RootedPath, FileStateValue> resolveFromAncestors(
       RootedPath rootedPath, Environment env)
       throws FileFunctionException, InterruptedException {
-    PathFragment relativePath = rootedPath.getRelativePath();
+    PathFragment relativePath = rootedPath.getRootRelativePath();
     RootedPath realRootedPath = rootedPath;
     FileValue parentFileValue = null;
     PathFragment parentDirectory = relativePath.getParentDirectory();
@@ -130,8 +130,10 @@
       }
       PathFragment baseName = PathFragment.create(relativePath.getBaseName());
       RootedPath parentRealRootedPath = parentFileValue.realRootedPath();
-      realRootedPath = RootedPath.toRootedPath(parentRealRootedPath.getRoot(),
-          parentRealRootedPath.getRelativePath().getRelative(baseName));
+      realRootedPath =
+          RootedPath.toRootedPath(
+              parentRealRootedPath.getRoot(),
+              parentRealRootedPath.getRootRelativePath().getRelative(baseName));
 
       if (!parentFileValue.exists()) {
         return Pair.<RootedPath, FileStateValue>of(
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java b/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
index ad8fc99..53325ae 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
@@ -258,7 +258,7 @@
           (CollectPackagesUnderDirectoryValue) val;
       if (collectPackagesValue != null) {
         if (collectPackagesValue.isDirectoryPackage()) {
-          builder.add(info.rootedDir.getRelativePath());
+          builder.add(info.rootedDir.getRootRelativePath());
         }
 
         if (collectPackagesValue.getErrorMessage() != null) {
@@ -269,7 +269,7 @@
             collectPackagesValue.getSubdirectoryTransitivelyContainsPackagesOrErrors();
         for (RootedPath subdirectory : subdirectoryTransitivelyContainsPackages.keySet()) {
           if (subdirectoryTransitivelyContainsPackages.get(subdirectory)) {
-            PathFragment subdirectoryRelativePath = subdirectory.getRelativePath();
+            PathFragment subdirectoryRelativePath = subdirectory.getRootRelativePath();
             ImmutableSet<PathFragment> blacklistedSubdirectoriesBeneathThisSubdirectory =
                 info.blacklistedSubdirectories
                     .stream()
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java
index 66d4afa..6d6d2eb 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java
@@ -60,7 +60,7 @@
     // Is this the root directory? If so, we're in the MAIN repository. This assumes that the main
     // repository has a WORKSPACE in the root directory, but Bazel will have failed with an error
     // before this can be called if that is incorrect.
-    if (directory.getRelativePath().equals(PathFragment.EMPTY_FRAGMENT)) {
+    if (directory.getRootRelativePath().equals(PathFragment.EMPTY_FRAGMENT)) {
       return LocalRepositoryLookupValue.mainRepository();
     }
 
@@ -84,7 +84,7 @@
     // If we haven't found a repository yet, check the parent directory.
     RootedPath parentDirectory =
         RootedPath.toRootedPath(
-            directory.getRoot(), directory.getRelativePath().getParentDirectory());
+            directory.getRoot(), directory.getRootRelativePath().getParentDirectory());
     return env.getValue(LocalRepositoryLookupValue.key(parentDirectory));
   }
 
@@ -95,7 +95,7 @@
           RootedPath.toRootedPath(
               directory.getRoot(),
               directory
-                  .getRelativePath()
+                  .getRootRelativePath()
                   .getRelative(BuildFileName.WORKSPACE.getFilenameFragment()));
       FileValue workspaceFileValue =
           (FileValue) env.getValueOrThrow(FileValue.key(workspaceRootedFile), IOException.class);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunction.java
index 780254b..05ef591 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunction.java
@@ -81,7 +81,7 @@
                   CollectTargetsInPackageValue.key(
                       PackageIdentifier.create(
                           recursivePkgKey.getRepository(),
-                          recursivePkgKey.getRootedPath().getRelativePath()),
+                          recursivePkgKey.getRootedPath().getRootRelativePath()),
                       filteringPolicy)),
               keysToRequest);
     }
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java b/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
index ce995c9..6d1cf5a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java
@@ -75,7 +75,7 @@
       SkyFunction.Environment env,
       Set<PathFragment> excludedPaths)
       throws InterruptedException {
-    PathFragment rootRelativePath = rootedPath.getRelativePath();
+    PathFragment rootRelativePath = rootedPath.getRootRelativePath();
 
     SkyKey fileKey = FileValue.key(rootedPath);
     FileValue fileValue;
@@ -170,7 +170,7 @@
       RepositoryName repositoryName,
       Set<PathFragment> excludedPaths) {
     Root root = rootedPath.getRoot();
-    PathFragment rootRelativePath = rootedPath.getRelativePath();
+    PathFragment rootRelativePath = rootedPath.getRootRelativePath();
     boolean followSymlinks = shouldFollowSymlinksWhenTraversing(dirListingValue.getDirents());
     List<SkyKey> childDeps = new ArrayList<>();
     for (Dirent dirent : dirListingValue.getDirents()) {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java
index f72e436..a885bef 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java
@@ -137,7 +137,7 @@
 
     Map<SkyKey, SkyValue> subdirectorySkyValues;
     if (packageExistenceAndSubdirDeps.packageExists()) {
-      PathFragment rootRelativePath = rootedPath.getRelativePath();
+      PathFragment rootRelativePath = rootedPath.getRootRelativePath();
       SkyKey packageKey =
           PackageValue.key(
               PackageIdentifier.create(recursivePkgKey.getRepository(), rootRelativePath));
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java
index d8e569e..bc02d56 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java
@@ -54,10 +54,12 @@
   public static final class GeneratedPathConflictException extends
       RecursiveFilesystemTraversalException {
     GeneratedPathConflictException(TraversalRequest traversal) {
-      super(String.format(
-          "Generated directory %s conflicts with package under the same path. Additional info: %s",
-          traversal.path.getRelativePath().getPathString(),
-          traversal.errorInfo != null ? traversal.errorInfo : traversal.toString()));
+      super(
+          String.format(
+              "Generated directory %s conflicts with package under the same path. "
+                  + "Additional info: %s",
+              traversal.path.getRootRelativePath().getPathString(),
+              traversal.errorInfo != null ? traversal.errorInfo : traversal.toString()));
     }
   }
 
@@ -132,8 +134,10 @@
 
       if (rootInfo.type.isFile()) {
         if (traversal.pattern == null
-            || traversal.pattern.matcher(
-                   rootInfo.realPath.getRelativePath().getPathString()).matches()) {
+            || traversal
+                .pattern
+                .matcher(rootInfo.realPath.getRootRelativePath().getPathString())
+                .matches()) {
           // The root is a file or a symlink to one.
           return resultForFileRoot(traversal.path, rootInfo);
         } else {
@@ -152,8 +156,10 @@
             new GeneratedPathConflictException(traversal));
       } else if (pkgLookupResult.isPackage() && !traversal.skipTestingForSubpackage) {
         // The traversal was requested for a directory that defines a package.
-        String msg = traversal.errorInfo + " crosses package boundary into package rooted at "
-            + traversal.path.getRelativePath().getPathString();
+        String msg =
+            traversal.errorInfo
+                + " crosses package boundary into package rooted at "
+                + traversal.path.getRootRelativePath().getPathString();
         switch (traversal.crossPkgBoundaries) {
           case CROSS:
             // We are free to traverse the subpackage but we need to display a warning.
@@ -298,8 +304,9 @@
       throws MissingDepException, IOException, InterruptedException {
     Preconditions.checkArgument(rootInfo.type.exists() && !rootInfo.type.isFile(),
         "{%s} {%s}", traversal, rootInfo);
-    PackageLookupValue pkgLookup = (PackageLookupValue) getDependentSkyValue(env,
-        PackageLookupValue.key(traversal.path.getRelativePath()));
+    PackageLookupValue pkgLookup =
+        (PackageLookupValue)
+            getDependentSkyValue(env, PackageLookupValue.key(traversal.path.getRootRelativePath()));
 
     if (pkgLookup.packageExists()) {
       if (traversal.isGenerated) {
@@ -340,8 +347,10 @@
 
     List<SkyKey> result = new ArrayList<>();
     for (Dirent dirent : dirListing.getDirents()) {
-      RootedPath childPath = RootedPath.toRootedPath(traversal.path.getRoot(),
-          traversal.path.getRelativePath().getRelative(dirent.getName()));
+      RootedPath childPath =
+          RootedPath.toRootedPath(
+              traversal.path.getRoot(),
+              traversal.path.getRootRelativePath().getRelative(dirent.getName()));
       TraversalRequest childTraversal = traversal.forChildEntry(childPath);
       result.add(RecursiveFilesystemTraversalValue.key(childTraversal));
     }
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalValue.java
index d3bbc16..e791b5c 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalValue.java
@@ -168,8 +168,8 @@
      * originally assumed.
      */
     TraversalRequest forChangedRootPath(Root newRoot) {
-      return duplicate(RootedPath.toRootedPath(newRoot, path.getRelativePath()),
-          skipTestingForSubpackage);
+      return duplicate(
+          RootedPath.toRootedPath(newRoot, path.getRootRelativePath()), skipTestingForSubpackage);
     }
 
     @Override
@@ -214,7 +214,7 @@
     }
 
     PathFragment getNameInSymlinkTree() {
-      return linkName.getRelativePath();
+      return linkName.getRootRelativePath();
     }
 
     @Override
@@ -301,7 +301,7 @@
 
     @Override
     public PathFragment getNameInSymlinkTree() {
-      return path.getRelativePath();
+      return path.getRootRelativePath();
     }
 
     @Override
@@ -360,7 +360,7 @@
 
     @Override
     public PathFragment getNameInSymlinkTree() {
-      return path.getRelativePath();
+      return path.getRootRelativePath();
     }
 
     @Override
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursivePkgValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursivePkgValue.java
index 20919a0..74f94bf 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursivePkgValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursivePkgValue.java
@@ -83,8 +83,7 @@
 
     public RecursivePkgKey(RepositoryName repositoryName, RootedPath rootedPath,
         ImmutableSet<PathFragment> excludedPaths) {
-      PathFragment.checkAllPathsAreUnder(excludedPaths,
-          rootedPath.getRelativePath());
+      PathFragment.checkAllPathsAreUnder(excludedPaths, rootedPath.getRootRelativePath());
       Preconditions.checkState(!repositoryName.isDefault());
       this.repositoryName = repositoryName;
       this.rootedPath = Preconditions.checkNotNull(rootedPath);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index 9e0a419..c182d69 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -984,7 +984,7 @@
         DirectoryListingStateValue oldDirListingStateValue =
             (DirectoryListingStateValue) valuesMap.get(dirListingStateKey);
         if (oldDirListingStateValue != null) {
-          String baseName = rootedPath.getRelativePath().getBaseName();
+          String baseName = rootedPath.getRootRelativePath().getBaseName();
           Dirent oldDirent = oldDirListingStateValue.getDirents().maybeGetDirent(baseName);
           changedType = (oldDirent == null)
               || !compatibleFileTypes(oldDirent.getType(), newValue.getType());
@@ -1005,8 +1005,9 @@
   }
 
   private static SkyKey parentDirectoryListingStateKey(RootedPath rootedPath) {
-    RootedPath parentDirRootedPath = RootedPath.toRootedPath(
-        rootedPath.getRoot(), rootedPath.getRelativePath().getParentDirectory());
+    RootedPath parentDirRootedPath =
+        RootedPath.toRootedPath(
+            rootedPath.getRoot(), rootedPath.getRootRelativePath().getParentDirectory());
     return DirectoryListingStateValue.key(parentDirRootedPath);
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java
index bb27716..462e51f 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeIncrementalBuildMonitor.java
@@ -20,7 +20,6 @@
 import com.google.devtools.build.lib.vfs.PathFragment;
 import com.google.devtools.build.lib.vfs.RootedPath;
 import com.google.devtools.build.skyframe.SkyKey;
-
 import java.util.HashSet;
 import java.util.Set;
 
@@ -40,7 +39,7 @@
     for (SkyKey skyKey : invalidatedValues) {
       if (skyKey.functionName().equals(SkyFunctions.FILE_STATE)) {
         RootedPath file = (RootedPath) skyKey.argument();
-        maybeAddFile(file.getRelativePath());
+        maybeAddFile(file.getRootRelativePath());
       }
     }
   }
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java
index 4c56ade..a36fd32 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java
@@ -53,7 +53,7 @@
       return null;
     }
 
-    Path repoWorkspace = workspaceRoot.getRoot().getRelative(workspaceRoot.getRelativePath());
+    Path repoWorkspace = workspaceRoot.getRoot().getRelative(workspaceRoot.getRootRelativePath());
     try {
       BuildFileAST ast = BuildFileAST.parseBuildFile(
           ParserInputSource.create(ruleClassProvider.getDefaultWorkspacePrefix(),
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java
index 3f0f3f8..945ecfe 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java
@@ -72,7 +72,7 @@
       return null;
     }
 
-    Path repoWorkspace = workspaceRoot.getRoot().getRelative(workspaceRoot.getRelativePath());
+    Path repoWorkspace = workspaceRoot.getRoot().getRelative(workspaceRoot.getRootRelativePath());
     Package.Builder builder = packageFactory.newExternalPackageBuilder(
         repoWorkspace, ruleClassProvider.getRunfilesPrefix());
 
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/FsUtils.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/FsUtils.java
index 53962ba..29cb354 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/FsUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/FsUtils.java
@@ -37,6 +37,6 @@
 
   /** Returns path relative to {@link #TEST_ROOT}. */
   public static PathFragment rootPathRelative(String path) {
-    return TEST_ROOT.getRelativePath().getRelative(path);
+    return TEST_ROOT.getRootRelativePath().getRelative(path);
   }
 }