use of com.facebook.buck.util.autosparse.AutoSparseProjectFilesystemDelegate in project buck by facebook.
the class ProjectFilesystemDelegateFactory method newInstance.
/**
* Must always create a new delegate for the specified {@code root}.
*/
public static ProjectFilesystemDelegate newInstance(Path root, String hgCmd, AutoSparseConfig autoSparseConfig) {
Optional<EdenClient> client = tryToCreateEdenClient();
if (client.isPresent()) {
try {
EdenMount mount = client.get().getMountFor(root);
if (mount != null) {
return new EdenProjectFilesystemDelegate(mount);
}
} catch (TException | EdenError e) {
// If Eden is running but root is not a mount point, Eden getMountFor() should just return
// null rather than throw an error.
LOG.error(e, "Failed to find Eden client for %s.", root);
}
}
if (autoSparseConfig.enabled()) {
// We can't access BuckConfig because that class requires a
// ProjectFileSystem, which we are in the process of building
// Access the required info from the Config instead
HgCmdLineInterface hgCmdLine = new HgCmdLineInterface(new PrintStreamProcessExecutorFactory(), root, hgCmd, ImmutableMap.of());
AutoSparseState autoSparseState = AbstractAutoSparseFactory.getAutoSparseState(root, hgCmdLine, autoSparseConfig);
if (autoSparseState != null) {
LOG.debug("Autosparse enabled, using AutoSparseProjectFilesystemDelegate");
return new AutoSparseProjectFilesystemDelegate(autoSparseState, root);
}
}
// No Eden or Mercurial info available, use the default
return new DefaultProjectFilesystemDelegate(root);
}
Aggregations