Search in sources :

Example 6 with VcsRoot

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

the class LocalChangesUnderRoots method getRootForPath.

@Nullable
private VirtualFile getRootForPath(@NotNull FilePath file, @NotNull Collection<VirtualFile> rootsToSave) {
    final VirtualFile vf = ChangesUtil.findValidParentUnderReadAction(file);
    if (vf == null) {
        return null;
    }
    VirtualFile rootCandidate = null;
    for (VcsRoot root : myRoots) {
        if (VfsUtilCore.isAncestor(root.getPath(), vf, false)) {
            if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.getPath(), true)) {
                // in the case of nested roots choose the closest root
                rootCandidate = root.getPath();
            }
        }
    }
    if (!rootsToSave.contains(rootCandidate))
        return null;
    return rootCandidate;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot 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 8 with VcsRoot

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

the class CvsCheckinHandlerFactory method createVcsHandler.

@NotNull
@Override
protected CheckinHandler createVcsHandler(final CheckinProjectPanel panel) {
    return new CheckinHandler() {

        @Nullable
        public RefreshableOnComponent getAfterCheckinConfigurationPanel(Disposable parentDisposable) {
            final Project project = panel.getProject();
            final CvsVcs2 cvs = CvsVcs2.getInstance(project);
            final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
            final Collection<VirtualFile> roots = panel.getRoots();
            final Collection<FilePath> files = new HashSet<>();
            for (VirtualFile root : roots) {
                final VcsRoot vcsRoot = vcsManager.getVcsRootObjectFor(root);
                if (vcsRoot == null || vcsRoot.getVcs() != cvs) {
                    continue;
                }
                files.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(root));
            }
            return new AdditionalOptionsPanel(CvsConfiguration.getInstance(project), files, project);
        }
    };
}
Also used : Disposable(com.intellij.openapi.Disposable) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) Project(com.intellij.openapi.project.Project) CheckinHandler(com.intellij.openapi.vcs.checkin.CheckinHandler) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AdditionalOptionsPanel(com.intellij.cvsSupport2.checkinProject.AdditionalOptionsPanel) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with VcsRoot

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

the class VcsRootDetectorImpl method scanForRootsInContentRoots.

@NotNull
private Set<VcsRoot> scanForRootsInContentRoots() {
    Set<VcsRoot> vcsRoots = new HashSet<>();
    if (myProject.isDisposed())
        return vcsRoots;
    VirtualFile[] roots = myProjectManager.getContentRoots();
    for (VirtualFile contentRoot : roots) {
        Set<VcsRoot> rootsInsideRoot = scanForRootsInsideDir(contentRoot);
        boolean shouldScanAbove = true;
        for (VcsRoot root : rootsInsideRoot) {
            if (contentRoot.equals(root.getPath())) {
                shouldScanAbove = false;
            }
        }
        if (shouldScanAbove) {
            List<VcsRoot> rootsAbove = scanForSingleRootAboveDir(contentRoot);
            rootsInsideRoot.addAll(rootsAbove);
        }
        vcsRoots.addAll(rootsInsideRoot);
    }
    return vcsRoots;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot 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

VcsRoot (com.intellij.openapi.vcs.VcsRoot)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 NotNull (org.jetbrains.annotations.NotNull)8 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)7 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 Disposable (com.intellij.openapi.Disposable)2 Project (com.intellij.openapi.project.Project)2 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)2 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 AdditionalOptionsPanel (com.intellij.cvsSupport2.checkinProject.AdditionalOptionsPanel)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 FileChooser (com.intellij.openapi.fileChooser.FileChooser)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1