blob: 973ce16d43b81245457cc9441a8bf65c033eb862 [file] [log] [blame]
/*
* Copyright 2016 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.base.vcs;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.google.idea.blaze.base.projectview.ProjectViewSet;
import com.google.idea.blaze.base.scope.BlazeContext;
import com.google.idea.blaze.base.sync.workspace.BlazeRoots;
import com.google.idea.blaze.base.sync.workspace.WorkingSet;
import com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import javax.annotation.Nullable;
/**
* Provides a diff against the version control system.
*/
public interface BlazeVcsHandler {
ExtensionPointName<BlazeVcsHandler> EP_NAME = ExtensionPointName.create("com.google.idea.blaze.VcsHandler");
/**
* Optionally returns a client name if the supplied workspace root corresponds to this VCS type.
*/
@Nullable
String getClientName(WorkspaceRoot workspaceRoot);
/**
* Returns whether this vcs handler can manage this project
*/
boolean handlesProject(Project project, WorkspaceRoot workspaceRoot);
/**
* Returns the working set of modified files compared to some "upstream".
*/
ListenableFuture<WorkingSet> getWorkingSet(Project project,
WorkspaceRoot workspaceRoot,
ListeningExecutorService executor);
/**
* Optionally creates a sync handler to perform vcs-specific computation during sync.
*/
@Nullable
BlazeVcsSyncHandler createSyncHandler(Project project, WorkspaceRoot workspaceRoot);
interface BlazeVcsSyncHandler {
enum ValidationResult {
OK,
Error,
RestartSync, /** The sync process needs restarting **/
}
/**
* Updates the vcs state of the project.
*
* @return True for OK, false to abort the sync process.
*/
boolean update(BlazeContext context, BlazeRoots blazeRoots, ListeningExecutorService executor);
/**
* Returns a custom workspace path resolver for this vcs.
*/
@Nullable
WorkspacePathResolver getWorkspacePathResolver();
/**
* Validates the project view. Can cause sync to fail or restart.
*/
ValidationResult validateProjectView(BlazeContext context, ProjectViewSet projectViewSet);
}
}