Search in sources :

Example 16 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.

the class VcsContentAnnotationImpl method fileRecentlyChanged.

@Nullable
@Override
public VcsRevisionNumber fileRecentlyChanged(VirtualFile vf) {
    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
    final AbstractVcs vcs = vcsManager.getVcsFor(vf);
    if (vcs == null)
        return null;
    if (vcs.getDiffProvider() instanceof DiffMixin) {
        final VcsRevisionDescription description = ((DiffMixin) vcs.getDiffProvider()).getCurrentRevisionDescription(vf);
        final Date date = description.getRevisionDate();
        return isRecent(date) ? description.getRevisionNumber() : null;
    }
    return null;
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) DiffMixin(com.intellij.openapi.vcs.diff.DiffMixin) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) VcsRevisionDescription(com.intellij.openapi.vcs.history.VcsRevisionDescription) Date(java.util.Date) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.

the class AbstractShowDiffAction method isEnabled.

private static boolean isEnabled(@NotNull Project project, @NotNull VirtualFile file, @Nullable VcsBackgroundableActions actionKey) {
    boolean result = false;
    if (!file.isDirectory() && (actionKey == null || !BackgroundableActionLock.isLocked(project, actionKey, VcsBackgroundableActions.keyFrom(file)))) {
        AbstractVcs vcs = ChangesUtil.getVcsForFile(file, project);
        result = vcs != null && vcs.getDiffProvider() != null && AbstractVcs.fileInVcsByFileStatus(project, VcsUtil.getFilePath(file));
    }
    return result;
}
Also used : AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 18 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.

the class CheckinHandlersManagerImpl method getRegisteredCheckinHandlerFactories.

@Override
public List<BaseCheckinHandlerFactory> getRegisteredCheckinHandlerFactories(AbstractVcs<?>[] allActiveVcss) {
    final List<BaseCheckinHandlerFactory> list = new ArrayList<>(myRegisteredBeforeCheckinHandlers.size() + allActiveVcss.length);
    for (AbstractVcs vcs : allActiveVcss) {
        final Collection<VcsCheckinHandlerFactory> factories = myVcsMap.get(vcs.getKeyInstanceMethod());
        if (!factories.isEmpty()) {
            list.addAll(factories);
        }
    }
    list.addAll(myRegisteredBeforeCheckinHandlers);
    return list;
}
Also used : VcsCheckinHandlerFactory(com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory) ArrayList(java.util.ArrayList) BaseCheckinHandlerFactory(com.intellij.openapi.vcs.checkin.BaseCheckinHandlerFactory) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 19 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.

the class VcsLogManager method findLogProviders.

@NotNull
public static Map<VirtualFile, VcsLogProvider> findLogProviders(@NotNull Collection<VcsRoot> roots, @NotNull Project project) {
    Map<VirtualFile, VcsLogProvider> logProviders = ContainerUtil.newHashMap();
    VcsLogProvider[] allLogProviders = Extensions.getExtensions(VcsLogProvider.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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with AbstractVcs

use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.

the class VcsRootDetectorImpl method scanForRootsInsideDir.

@NotNull
private Set<VcsRoot> scanForRootsInsideDir(@NotNull final VirtualFile dir, final int depth) {
    LOG.debug("Scanning inside [" + dir + "], depth = " + depth);
    final Set<VcsRoot> roots = new HashSet<>();
    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);
    LOG.debug("Found following VCSs: " + vcsList);
    for (AbstractVcs vcs : vcsList) {
        roots.add(new VcsRoot(vcs, dir));
    }
    for (VirtualFile child : dir.getChildren()) {
        roots.addAll(scanForRootsInsideDir(child, depth + 1));
    }
    return roots;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 NotNull (org.jetbrains.annotations.NotNull)12 Project (com.intellij.openapi.project.Project)9 FilePath (com.intellij.openapi.vcs.FilePath)7 VcsRoot (com.intellij.openapi.vcs.VcsRoot)7 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)6 Nullable (org.jetbrains.annotations.Nullable)5 Module (com.intellij.openapi.module.Module)3 VcsDirectoryMapping (com.intellij.openapi.vcs.VcsDirectoryMapping)3 VcsKey (com.intellij.openapi.vcs.VcsKey)3 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)3 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)3 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 Date (java.util.Date)3 Pair (com.intellij.openapi.util.Pair)2 VcsException (com.intellij.openapi.vcs.VcsException)2 DiffProvider (com.intellij.openapi.vcs.diff.DiffProvider)2 VcsHistorySession (com.intellij.openapi.vcs.history.VcsHistorySession)2 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)2