Support file renaming in ActionFS.

PiperOrigin-RevId: 199850381
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
index 5abb9c8..fb4ead3 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionFileSystem.java
@@ -465,7 +465,13 @@
 
   @Override
   public void renameTo(Path sourcePath, Path targetPath) throws IOException {
-    throw new UnsupportedOperationException("renameTo(" + sourcePath + ", " + targetPath + ")");
+    PathFragment sourceExecPath = asExecPath(sourcePath);
+    OutputMetadata sourceMetadata = outputs.getIfPresent(sourceExecPath);
+    if (sourceMetadata == null) {
+      throw new IOException("No output file at " + sourcePath + " to move to " + targetPath);
+    }
+    outputs.put(asExecPath(targetPath), sourceMetadata);
+    outputs.invalidate(sourceExecPath);
   }
 
   @Override