Search in sources :

Example 36 with AbstractVcs

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

the class AbstractShowDiffAction method actionPerformed.

@Override
protected void actionPerformed(@NotNull VcsContext vcsContext) {
    Project project = assertNotNull(vcsContext.getProject());
    if (!ChangeListManager.getInstance(project).isFreezedWithNotification("Can not " + vcsContext.getActionName() + " now")) {
        VirtualFile file = vcsContext.getSelectedFiles()[0];
        AbstractVcs vcs = assertNotNull(ChangesUtil.getVcsForFile(file, project));
        DiffProvider provider = assertNotNull(vcs.getDiffProvider());
        getExecutor(provider, file, project).showDiff();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DiffProvider(com.intellij.openapi.vcs.diff.DiffProvider) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 37 with AbstractVcs

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

the class IgnoredFilesCompositeHolder method cleanAndAdjustScope.

@Override
public void cleanAndAdjustScope(VcsModifiableDirtyScope scope) {
    final AbstractVcs vcs = scope.getVcs();
    if (myVcsIgnoredHolderMap.containsKey(vcs)) {
        myVcsIgnoredHolderMap.get(vcs).cleanAndAdjustScope(scope);
    }
    myIdeIgnoredFilesHolder.cleanAndAdjustScope(scope);
}
Also used : AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 38 with AbstractVcs

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

the class ModuleDefaultVcsRootPolicy method getDefaultVcsRoots.

@Override
@NotNull
public Collection<VirtualFile> getDefaultVcsRoots(@NotNull NewMappings mappingList, @NotNull String vcsName) {
    Set<VirtualFile> result = newHashSet();
    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
    if (myBaseDir != null && vcsName.equals(mappingList.getVcsFor(myBaseDir))) {
        final AbstractVcs vcsFor = vcsManager.getVcsFor(myBaseDir);
        if (vcsFor != null && vcsName.equals(vcsFor.getName())) {
            result.add(myBaseDir);
        }
    }
    if (ProjectKt.isDirectoryBased(myProject) && myBaseDir != null) {
        final VirtualFile ideaDir = ProjectKt.getStateStore(myProject).getDirectoryStoreFile();
        if (ideaDir != null) {
            final AbstractVcs vcsFor = vcsManager.getVcsFor(ideaDir);
            if (vcsFor != null && vcsName.equals(vcsFor.getName())) {
                result.add(ideaDir);
            }
        }
    }
    // assertion for read access inside
    Module[] modules = ReadAction.compute(myModuleManager::getModules);
    for (Module module : modules) {
        final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
        for (VirtualFile file : files) {
            // if we're currently processing moduleAdded notification, getModuleForFile() will return null, so we pass the module
            // explicitly (we know it anyway)
            VcsDirectoryMapping mapping = mappingList.getMappingFor(file, module);
            final String mappingVcs = mapping != null ? mapping.getVcs() : null;
            if (vcsName.equals(mappingVcs) && file.isDirectory()) {
                result.add(file);
            }
        }
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) Module(com.intellij.openapi.module.Module) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with AbstractVcs

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

the class ModuleVcsDetector method autoDetectModuleVcsMapping.

private void autoDetectModuleVcsMapping(final Module module) {
    boolean mappingsUpdated = false;
    final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
    for (VirtualFile file : files) {
        AbstractVcs vcs = myVcsManager.findVersioningVcs(file);
        if (vcs != null && vcs != myVcsManager.getVcsFor(file)) {
            myVcsManager.setAutoDirectoryMapping(file.getPath(), vcs.getName());
            mappingsUpdated = true;
        }
    }
    if (mappingsUpdated) {
        myVcsManager.cleanupMappings();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 40 with AbstractVcs

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

the class AllVcses method getByName.

public AbstractVcs getByName(final String name) {
    synchronized (myLock) {
        final AbstractVcs vcs = myVcses.get(name);
        if (vcs != null) {
            return vcs;
        }
    }
    // unmodifiable map => no sync needed
    final VcsEP ep = myExtensions.get(name);
    if (ep == null) {
        return null;
    }
    // VcsEP guarantees to always return the same vcs value
    final AbstractVcs vcs1 = ep.getVcs(myProject);
    LOG.assertTrue(vcs1 != null, name);
    synchronized (myLock) {
        if (!myVcses.containsKey(name)) {
            addVcs(vcs1);
        }
        return vcs1;
    }
}
Also used : VcsEP(com.intellij.openapi.vcs.impl.VcsEP) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

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