new_local_repo: fix correctness bug with glob()

In Skyframe, the DirectoryListingStateValue (DLS)
of an external repository's path will now depend
on the RepositoryDirectoryValue (RD).

Example: the DLS of [output_root]/external/X now
depends on the RD of `@X`.

This is relevant for `glob()` expressions in the
top-level package of the repository. The GlobValue
depends on the DLS in order to get notified about
added/removed files. In the root of external
directories, those files are added/removed by the
repository function. Hence the DLS should depend
on the evaluation of the repository function, i.e.
the creation of the RD. And that is exactly what
this commit now does -- it ensures this dependency
is declared.

The bugfix is specific to Windows. On Linux,
GlobValue depends on the DLS, but it also depends
on symlinks in the directory (to get notified
about a directory symlink getting replaced by a
file with the same name, which would affect
recursive globbing). And the symlinks depend on
the RD, so the GlobValue always depended on the
RD.

However on Windows the files in the root of the
repository are copies, not symlinks, and the Glob
does not depend on files (as a means of
optimization), so on Windows the GlobValue didn't
depend on the RD, which caused issue #6351.

More info: https://github.com/bazelbuild/bazel/issues/6351#issuecomment-465488344

Fixes https://github.com/bazelbuild/bazel/issues/6351

Closes #7473.

PiperOrigin-RevId: 234938677
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java b/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java
index aa7f036..abc7577 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java
@@ -197,15 +197,15 @@
   }
 
   /**
-   * If this instance is configured with
-   * {@link ExternalFileAction#DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS} and
-   * {@code rootedPath} isn't under a package root then this adds a dependency on the //external
-   * package. If the action is
+   * If this instance is configured with {@link
+   * ExternalFileAction#DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS} and {@code rootedPath} isn't
+   * under a package root then this adds a dependency on the //external package. If the action is
    * {@link ExternalFileAction#ASSUME_NON_EXISTENT_AND_IMMUTABLE_FOR_EXTERNAL_PATHS}, it will throw
    * a {@link NonexistentImmutableExternalFileException} instead.
    */
   @ThreadSafe
-  void maybeHandleExternalFile(RootedPath rootedPath, SkyFunction.Environment env)
+  void maybeHandleExternalFile(
+      RootedPath rootedPath, boolean isDirectory, SkyFunction.Environment env)
       throws NonexistentImmutableExternalFileException, IOException, InterruptedException {
     FileType fileType = getAndNoteFileType(rootedPath);
     if (fileType == FileType.INTERNAL) {
@@ -225,6 +225,6 @@
     Preconditions.checkState(
         externalFileAction == ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS,
         externalFileAction);
-    RepositoryFunction.addExternalFilesDependencies(rootedPath, directories, env);
+    RepositoryFunction.addExternalFilesDependencies(rootedPath, isDirectory, directories, env);
   }
 }