From 91a7a34fb46fa04165ac90ca095d1272f2a39327 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Thu, 16 Jun 2016 14:55:33 +0000 Subject: Create mark file for local repositories, too Local repositories were not marked, so if a WS file switched from remote->local->remote, on the first run the remote rule would create a mark file, on the second run the local rule would ignore it, and then on the third run the remote rule would look at the mark file and see, "I'm already up-to-date," leaving the repository as a local repo. Fixes #977. -- MOS_MIGRATED_REVID=125060180 --- .../repository/RepositoryDelegatorFunction.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules') 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 cede852c67..8f15451230 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 @@ -113,26 +113,30 @@ public final class RepositoryDelegatorFunction implements SkyFunction { Path repoRoot = RepositoryFunction.getExternalRepositoryDirectory(directories).getRelative(rule.getName()); + byte[] ruleSpecificData = handler.getRuleSpecificMarkerData(rule, env); + if (ruleSpecificData == null) { + return null; + } + byte[] ruleKey = computeRuleKey(rule, ruleSpecificData); + Path markerPath = getMarkerPath(directories, rule); handler.setClientEnvironment(clientEnvironment); if (handler.isLocal(rule)) { // Local repositories are always fetched because the operation is generally fast and they do - // not depend on non-local data, so it does not make much sense to try to catch from across + // not depend on non-local data, so it does not make much sense to try to cache from across // server instances. setupRepositoryRoot(repoRoot); - return handler.fetch(rule, repoRoot, directories, env); + SkyValue localRepo = handler.fetch(rule, repoRoot, directories, env); + if (localRepo != null) { + writeMarkerFile(markerPath, ruleKey); + } + return localRepo; } // We check the repository root for existence here, but we can't depend on the FileValue, // because it's possible that we eventually create that directory in which case the FileValue // and the state of the file system would be inconsistent. - byte[] ruleSpecificData = handler.getRuleSpecificMarkerData(rule, env); - if (ruleSpecificData == null) { - return null; - } - byte[] ruleKey = computeRuleKey(rule, ruleSpecificData); - Path markerPath = getMarkerPath(directories, rule); boolean markerUpToDate = isFilesystemUpToDate(markerPath, ruleKey); if (markerUpToDate && repoRoot.exists()) { // Now that we know that it exists, we can declare a Skyframe dependency on the repository -- cgit v1.2.3