本文整理汇总了Java中com.intellij.openapi.vcs.AbstractVcs类的典型用法代码示例。如果您正苦于以下问题:Java AbstractVcs类的具体用法?Java AbstractVcs怎么用?Java AbstractVcs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractVcs类属于com.intellij.openapi.vcs包,在下文中一共展示了AbstractVcs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentBranch
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
public String getCurrentBranch(Project project) {
AbstractVcs[] VCS = ProjectLevelVcsManager.getInstance(project).getAllActiveVcss();
if (VCS.length == 0) {
return "";
}
AbstractVcs currentVersionControl = VCS[0];
if (currentVersionControl.getName().equalsIgnoreCase("hg4idea")) {
currentBranch = RepoHelper.getHgBranch(project);
} else if (currentVersionControl.getName().equalsIgnoreCase("Git")) {
currentBranch = RepoHelper.getGitBranch(project);
}
return currentBranch;
}
示例2: findLogProviders
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@NotNull
public static Map<VirtualFile, VcsLogProvider> findLogProviders(@NotNull Collection<VcsRoot> roots, @NotNull Project project) {
Map<VirtualFile, VcsLogProvider> logProviders = ContainerUtil.newHashMap();
VcsLogProvider[] allLogProviders = Extensions.getExtensions(LOG_PROVIDER_EP, project);
for (VcsRoot root : roots) {
AbstractVcs vcs = root.getVcs();
VirtualFile path = root.getPath();
if (vcs == null || path == null) {
LOG.error("Skipping invalid VCS root: " + root);
continue;
}
for (VcsLogProvider provider : allLogProviders) {
if (provider.getSupportedVcs().equals(vcs.getKeyInstanceMethod())) {
logProviders.put(path, provider);
break;
}
}
}
return logProviders;
}
示例3: findNewRoots
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@NotNull
private Map<VirtualFile, Repository> findNewRoots(@NotNull Set<VirtualFile> knownRoots) {
Map<VirtualFile, Repository> newRootsMap = ContainerUtil.newHashMap();
for (VcsRoot root : myVcsManager.getAllVcsRoots()) {
VirtualFile rootPath = root.getPath();
if (rootPath != null && !knownRoots.contains(rootPath)) {
AbstractVcs vcs = root.getVcs();
VcsRepositoryCreator repositoryCreator = getRepositoryCreator(vcs);
if (repositoryCreator == null) continue;
Repository repository = repositoryCreator.createRepositoryIfValid(rootPath);
if (repository != null) {
newRootsMap.put(rootPath, repository);
}
}
}
return newRootsMap;
}
示例4: AnnotatePreviousRevisionAction
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
public AnnotatePreviousRevisionAction(@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
super("Annotate Previous Revision", "Annotate successor of selected revision in new tab", AllIcons.Actions.Annotate,
annotation, vcs);
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null) {
myRevisions = null;
return;
}
Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<VcsRevisionNumber, VcsFileRevision>();
for (int i = 0; i < revisions.size(); i++) {
VcsFileRevision revision = revisions.get(i);
VcsFileRevision previousRevision = i + 1 < revisions.size() ? revisions.get(i + 1) : null;
map.put(revision.getRevisionNumber(), previousRevision);
}
myRevisions = new ArrayList<VcsFileRevision>(annotation.getLineCount());
for (int i = 0; i < annotation.getLineCount(); i++) {
myRevisions.add(map.get(annotation.getLineRevisionNumber(i)));
}
}
示例5: fillActions
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
protected void fillActions(@Nullable final Project project,
@NotNull final DefaultActionGroup group,
@NotNull final DataContext dataContext) {
if (project == null) {
return;
}
final Pair<SupportedVCS, AbstractVcs> typeAndVcs = getActiveVCS(project, dataContext);
final AbstractVcs vcs = typeAndVcs.getSecond();
final SupportedVCS popupType = typeAndVcs.getFirst();
switch (popupType) {
case VCS:
fillVcsPopup(project, group, dataContext, vcs);
break;
case NOT_IN_VCS:
fillNonInVcsActions(project, group, dataContext);
break;
}
}
示例6: fillVcsPopup
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
private void fillVcsPopup(@NotNull final Project project,
@NotNull final DefaultActionGroup group,
@Nullable final DataContext dataContext,
@Nullable final AbstractVcs vcs) {
if (vcs != null) {
// replace general vcs actions if necessary
for (VcsQuickListContentProvider provider : VcsQuickListContentProvider.EP_NAME.getExtensions()) {
if (provider.replaceVcsActionsFor(vcs, dataContext)) {
final List<AnAction> actionsToReplace = provider.getVcsActions(project, vcs, dataContext);
if (actionsToReplace != null) {
// replace general actions with custom ones:
addActions(actionsToReplace, group);
// local history
addLocalHistoryActions(group);
return;
}
}
}
}
// general list
fillGeneralVcsPopup(project, group, dataContext, vcs);
}
示例7: getActiveVCS
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
private Pair<SupportedVCS, AbstractVcs> getActiveVCS(@NotNull final Project project, @Nullable final DataContext dataContext) {
final AbstractVcs[] activeVcss = getActiveVCSs(project);
if (activeVcss.length == 0) {
// no vcs
return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.NOT_IN_VCS, null);
} else if (activeVcss.length == 1) {
// get by name
return Pair.create(SupportedVCS.VCS, activeVcss[0]);
}
// by current file
final VirtualFile file = dataContext != null ? CommonDataKeys.VIRTUAL_FILE.getData(dataContext) : null;
if (file != null) {
final AbstractVcs vscForFile = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
if (vscForFile != null) {
return Pair.create(SupportedVCS.VCS, vscForFile);
}
}
return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, null);
}
示例8: processDeletedFile
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
private boolean processDeletedFile(final VirtualFile file) throws IOException {
if (myInternalDelete) return false;
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file);
if (vcs != CvsVcs2.getInstance(myProject)) return false;
file.putUserData(CvsStorageSupportingDeletionComponent.FILE_VCS, vcs);
if (!CvsUtil.fileIsUnderCvs(file)) return false;
myComponent.getDeleteHandler().addDeletedRoot(file);
if (file.isDirectory()) {
myInternalDelete = true;
try {
deleteFilesInVFS(file);
}
finally {
myInternalDelete = false;
}
return true;
}
return false;
}
示例9: scanForRootsInsideDir
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@NotNull
private Set<VcsRoot> scanForRootsInsideDir(@NotNull final VirtualFile dir, final int depth) {
final Set<VcsRoot> roots = new HashSet<VcsRoot>();
if (depth > MAXIMUM_SCAN_DEPTH) {
// performance optimization via limitation: don't scan deep though the whole VFS, 2 levels under a content root is enough
return roots;
}
if (myProject.isDisposed() || !dir.isDirectory()) {
return roots;
}
List<AbstractVcs> vcsList = getVcsListFor(dir);
for (AbstractVcs vcs : vcsList) {
roots.add(new VcsRoot(vcs, dir));
}
for (VirtualFile child : dir.getChildren()) {
roots.addAll(scanForRootsInsideDir(child, depth + 1));
}
return roots;
}
示例10: scanForSingleRootAboveDir
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@NotNull
private List<VcsRoot> scanForSingleRootAboveDir(@NotNull final VirtualFile dir) {
List<VcsRoot> roots = new ArrayList<VcsRoot>();
if (myProject.isDisposed()) {
return roots;
}
VirtualFile par = dir.getParent();
while (par != null) {
List<AbstractVcs> vcsList = getVcsListFor(par);
for (AbstractVcs vcs : vcsList) {
roots.add(new VcsRoot(vcs, par));
}
if (!roots.isEmpty()) {
return roots;
}
par = par.getParent();
}
return roots;
}
示例11: processFiles
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
protected List<VcsException> processFiles(final AbstractVcs vcs, final List<FilePath> files) {
RollbackEnvironment environment = vcs.getRollbackEnvironment();
if (environment == null) return Collections.emptyList();
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.setText(vcs.getDisplayName() + ": performing rollback...");
}
final List<VcsException> result = new ArrayList<VcsException>(0);
try {
environment.rollbackMissingFileDeletion(files, result, new RollbackProgressModifier(files.size(), indicator));
}
catch (ProcessCanceledException e) {
// for files refresh
}
LocalFileSystem.getInstance().refreshIoFiles(ChangesUtil.filePathsToFiles(files));
return result;
}
示例12: getRollbackOperationName
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
/**
* Finds the most appropriate name for the "Rollback" operation for the given VCSs.
* That is: iterates through the all {@link RollbackEnvironment#getRollbackOperationName() RollbackEnvironments} and picks
* the operation name if it is equal to all given VCSs.
* Otherwise picks the {@link DefaultRollbackEnvironment#ROLLBACK_OPERATION_NAME default name}.
* @param vcses affected VCSs.
* @return name for the "rollback" operation to be used in the UI.
*/
@NotNull
public static String getRollbackOperationName(@NotNull Collection<AbstractVcs> vcses) {
String operationName = null;
for (AbstractVcs vcs : vcses) {
final RollbackEnvironment rollbackEnvironment = vcs.getRollbackEnvironment();
if (rollbackEnvironment != null) {
if (operationName == null) {
operationName = rollbackEnvironment.getRollbackOperationName();
}
else if (!operationName.equals(rollbackEnvironment.getRollbackOperationName())) {
// if there are different names, use default
return DefaultRollbackEnvironment.ROLLBACK_OPERATION_NAME;
}
}
}
return operationName != null ? operationName : DefaultRollbackEnvironment.ROLLBACK_OPERATION_NAME;
}
示例13: calculateInvalidated
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@NotNull
private VcsInvalidated calculateInvalidated(@NotNull DirtBuilder dirt) {
MultiMap<AbstractVcs, FilePath> files = dirt.getFilesForVcs();
MultiMap<AbstractVcs, FilePath> dirs = dirt.getDirsForVcs();
if (dirt.isEverythingDirty()) {
dirs.putAllValues(getEverythingDirtyRoots());
}
Set<AbstractVcs> keys = ContainerUtil.union(files.keySet(), dirs.keySet());
Map<AbstractVcs, VcsDirtyScopeImpl> scopes = ContainerUtil.newHashMap();
for (AbstractVcs key : keys) {
VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(key, myProject);
scopes.put(key, scope);
scope.addDirtyData(dirs.get(key), files.get(key));
}
return new VcsInvalidated(new ArrayList<VcsDirtyScope>(scopes.values()), dirt.isEverythingDirty());
}
示例14: guessRepositoryForFile
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@Nullable
public static <T extends Repository> T guessRepositoryForFile(@NotNull Project project,
@NotNull RepositoryManager<T> manager,
@Nullable AbstractVcs vcs,
@Nullable VirtualFile file,
@Nullable String defaultRootPathValue) {
T repository = manager.getRepositoryForRoot(guessVcsRoot(project, file));
return repository != null ? repository : manager.getRepositoryForRoot(guessRootForVcs(project, vcs, defaultRootPathValue));
}
示例15: getPushSupport
import com.intellij.openapi.vcs.AbstractVcs; //导入依赖的package包/类
@Nullable
public static PushSupport getPushSupport(@NotNull final AbstractVcs vcs) {
return ContainerUtil.find(Extensions.getExtensions(PushSupport.PUSH_SUPPORT_EP, vcs.getProject()), new Condition<PushSupport>() {
@Override
public boolean value(final PushSupport support) {
return support.getVcs().equals(vcs);
}
});
}