Search in sources :

Example 6 with ProjectLevelVcsManager

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

the class DescindingFilesFilter method filterDescindingFiles.

@NotNull
public static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project) {
    final List<FilePath> result = new LinkedList<>();
    ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
    Arrays.sort(roots, FilePathComparator.getInstance());
    final Map<VcsKey, List<FilePath>> chains = new HashMap<>();
    for (FilePath root : roots) {
        final AbstractVcs vcs = manager.getVcsFor(root);
        if (vcs == null)
            continue;
        if (vcs.allowsNestedRoots()) {
            // just put into result: nested roots are allowed
            result.add(root);
            continue;
        }
        //if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
        final List<FilePath> chain = chains.get(vcs.getKeyInstanceMethod());
        if (chain == null) {
            final LinkedList<FilePath> newList = new LinkedList<>();
            newList.add(root);
            chains.put(vcs.getKeyInstanceMethod(), newList);
        } else {
            boolean failed = false;
            for (FilePath chainedPath : chain) {
                if (VfsUtilCore.isAncestor(chainedPath.getIOFile(), root.getIOFile(), false)) {
                    // do not take this root
                    failed = true;
                    break;
                }
            }
            if (!failed) {
                chain.add(root);
            }
        }
    }
    for (List<FilePath> filePaths : chains.values()) {
        result.addAll(filePaths);
    }
    return result.toArray(new FilePath[result.size()]);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsKey(com.intellij.openapi.vcs.VcsKey) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ProjectLevelVcsManager

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

the class StartUseVcsAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent e) {
    final VcsDataWrapper data = new VcsDataWrapper(e);
    final boolean enabled = data.enabled();
    if (!enabled) {
        return;
    }
    final StartUseVcsDialog dialog = new StartUseVcsDialog(data);
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        final String vcsName = dialog.getVcs();
        if (vcsName.length() > 0) {
            final ProjectLevelVcsManager manager = data.getManager();
            AbstractVcs vcs = manager.findVcsByName(vcsName);
            assert vcs != null : "No vcs found for name " + vcsName;
            vcs.enableIntegration();
        }
    }
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 8 with ProjectLevelVcsManager

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

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

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

the class GitInit method refreshAndConfigureVcsMappings.

public static void refreshAndConfigureVcsMappings(final Project project, final VirtualFile root, final String path) {
    VfsUtil.markDirtyAndRefresh(false, true, false, root);
    ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
    manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, GitVcs.NAME));
    manager.updateActiveVcss();
    VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(root);
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager)

Aggregations

ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)19 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)6 NotNull (org.jetbrains.annotations.NotNull)6 Project (com.intellij.openapi.project.Project)3 VcsDirectoryMapping (com.intellij.openapi.vcs.VcsDirectoryMapping)3 Nullable (org.jetbrains.annotations.Nullable)3 FilePath (com.intellij.openapi.vcs.FilePath)2 VcsException (com.intellij.openapi.vcs.VcsException)2 Date (java.util.Date)2 CvsContext (com.intellij.cvsSupport2.actions.cvsContext.CvsContext)1 AdditionalOptionsPanel (com.intellij.cvsSupport2.checkinProject.AdditionalOptionsPanel)1 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)1 CvsHandler (com.intellij.cvsSupport2.cvshandlers.CvsHandler)1 CvsTabbedWindow (com.intellij.cvsSupport2.ui.CvsTabbedWindow)1 Disposable (com.intellij.openapi.Disposable)1 Application (com.intellij.openapi.application.Application)1 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)1 ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)1 ExternalSystemSettingsListenerAdapter (com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter)1