Search in sources :

Example 1 with ProjectLevelVcsManager

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

the class ShareWholeProject method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final MyChecker checker = new MyChecker();
    checker.execute(e);
    if (!checker.isEnabled())
        return;
    final Project project = checker.getProject();
    final VirtualFile baseDir = project.getBaseDir();
    if (baseDir == null)
        return;
    boolean success = false;
    boolean excThrown = false;
    try {
        success = ShareProjectAction.share(project, baseDir);
    } catch (VcsException exc) {
        AbstractVcsHelper.getInstance(project).showError(exc, "Failed to Share Project");
        excThrown = true;
    } finally {
        // if success = false -> either action was cancelled or exception was thrown, so also check for exception
        if (success || excThrown) {
            baseDir.refresh(true, true, () -> ApplicationManager.getApplication().invokeLater(() -> {
                VcsDirtyScopeManager.getInstance(project).dirDirtyRecursively(project.getBaseDir());
                if (checker.isHadNoMappings() && SvnUtil.seemsLikeVersionedDir(baseDir)) {
                    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
                    vcsManager.setDirectoryMappings(Arrays.asList(new VcsDirectoryMapping("", SvnVcs.VCS_NAME)));
                }
            }, ModalityState.NON_MODAL, project.getDisposed()));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) VcsException(com.intellij.openapi.vcs.VcsException) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager)

Example 2 with ProjectLevelVcsManager

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

the class HgInit method updateDirectoryMappings.

// update vcs directory mappings if new repository was created inside the current project directory
private void updateDirectoryMappings(VirtualFile mapRoot) {
    if (myProject != null && (!myProject.isDefault()) && myProject.getBaseDir() != null && VfsUtil.isAncestor(myProject.getBaseDir(), mapRoot, false)) {
        mapRoot.refresh(false, false);
        final String path = mapRoot.equals(myProject.getBaseDir()) ? "" : mapRoot.getPath();
        ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(myProject);
        manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, HgVcs.VCS_NAME));
        manager.updateActiveVcss();
    }
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager)

Example 3 with ProjectLevelVcsManager

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

the class ExclusiveBackgroundVcsAction method run.

public static void run(final Project project, final Runnable action) {
    final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project);
    plVcsManager.startBackgroundVcsOperation();
    try {
        action.run();
    } finally {
        final Application application = ApplicationManager.getApplication();
        if (application.isDispatchThread()) {
            application.executeOnPooledThread(() -> plVcsManager.stopBackgroundVcsOperation());
        } else {
            plVcsManager.stopBackgroundVcsOperation();
        }
    }
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) Application(com.intellij.openapi.application.Application)

Example 4 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 5 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)

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