Search in sources :

Example 11 with ProjectLevelVcsManager

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

the class GithubShareAction method filterOutIgnored.

@NotNull
private static Collection<VirtualFile> filterOutIgnored(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
    return ContainerUtil.filter(files, file -> !changeListManager.isIgnoredFile(file) && !vcsManager.isIgnored(file));
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ProjectLevelVcsManager

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

the class ExternalSystemVcsRegistrar method handle.

@SuppressWarnings("unchecked")
public static void handle(@NotNull final Project project) {
    for (final ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
        final AbstractExternalSystemSettings settings = manager.getSettingsProvider().fun(project);
        settings.subscribe(new ExternalSystemSettingsListenerAdapter() {

            @Override
            public void onProjectsLinked(@NotNull final Collection linked) {
                List<VcsDirectoryMapping> newMappings = ContainerUtilRt.newArrayList();
                final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
                ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
                for (Object o : linked) {
                    final ExternalProjectSettings settings = (ExternalProjectSettings) o;
                    VirtualFile dir = fileSystem.refreshAndFindFileByPath(settings.getExternalProjectPath());
                    if (dir == null) {
                        continue;
                    }
                    if (!dir.isDirectory()) {
                        dir = dir.getParent();
                    }
                    newMappings.addAll(VcsUtil.findRoots(dir, project));
                }
                // There is a possible case that no VCS mappings are configured for the current project. There is a single
                // mapping like <Project> - <No VCS> then. We want to replace it if only one mapping to the project root dir
                // has been detected then.
                List<VcsDirectoryMapping> oldMappings = vcsManager.getDirectoryMappings();
                if (oldMappings.size() == 1 && newMappings.size() == 1 && StringUtil.isEmpty(oldMappings.get(0).getVcs())) {
                    VcsDirectoryMapping newMapping = newMappings.iterator().next();
                    String detectedDirPath = newMapping.getDirectory();
                    VirtualFile detectedDir = fileSystem.findFileByPath(detectedDirPath);
                    if (detectedDir != null && detectedDir.equals(project.getBaseDir())) {
                        newMappings.clear();
                        newMappings.add(new VcsDirectoryMapping("", newMapping.getVcs()));
                        vcsManager.setDirectoryMappings(newMappings);
                        return;
                    }
                }
                newMappings.addAll(oldMappings);
                vcsManager.setDirectoryMappings(newMappings);
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExternalSystemSettingsListenerAdapter(com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter) VcsDirectoryMapping(com.intellij.openapi.vcs.VcsDirectoryMapping) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Collection(java.util.Collection) List(java.util.List)

Example 13 with ProjectLevelVcsManager

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

the class DvcsUtil method addMappingIfSubRoot.

public static void addMappingIfSubRoot(@NotNull Project project, @NotNull String newRepositoryPath, @NotNull String vcsName) {
    if (project.getBasePath() != null && FileUtil.isAncestor(project.getBasePath(), newRepositoryPath, true)) {
        ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
        manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), newRepositoryPath, vcsName));
    }
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager)

Example 14 with ProjectLevelVcsManager

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

the class VcsCherryPickAction method getActiveCherryPickersForProject.

@NotNull
private static List<VcsCherryPicker> getActiveCherryPickersForProject(@Nullable final Project project) {
    if (project != null) {
        final ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project);
        AbstractVcs[] vcss = projectLevelVcsManager.getAllActiveVcss();
        return ContainerUtil.mapNotNull(vcss, vcs -> vcs != null ? VcsCherryPickManager.getInstance(project).getCherryPickerFor(vcs.getKeyInstanceMethod()) : null);
    }
    return ContainerUtil.emptyList();
}
Also used : ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with ProjectLevelVcsManager

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

the class VcsContentAnnotationImpl method intervalRecentlyChanged.

@Override
public boolean intervalRecentlyChanged(VirtualFile file, TextRange lineInterval, VcsRevisionNumber currentRevisionNumber) {
    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
    final AbstractVcs vcs = vcsManager.getVcsFor(file);
    if (vcs == null || vcs.getDiffProvider() == null)
        return false;
    if (currentRevisionNumber == null) {
        currentRevisionNumber = vcs.getDiffProvider().getCurrentRevision(file);
        assert currentRevisionNumber != null;
    }
    final ThreeState isRecent = myContentAnnotationCache.isRecent(file, vcs.getKeyInstanceMethod(), currentRevisionNumber, lineInterval, System.currentTimeMillis() - mySettings.getLimit());
    if (!ThreeState.UNSURE.equals(isRecent))
        return ThreeState.YES.equals(isRecent);
    final FileAnnotation fileAnnotation;
    try {
        fileAnnotation = vcs.getAnnotationProvider().annotate(file);
    } catch (VcsException e) {
        LOG.info(e);
        return false;
    }
    myContentAnnotationCache.register(file, vcs.getKeyInstanceMethod(), currentRevisionNumber, fileAnnotation);
    for (int i = lineInterval.getStartOffset(); i <= lineInterval.getEndOffset(); i++) {
        Date lineDate = fileAnnotation.getLineDate(i);
        if (lineDate != null && isRecent(lineDate))
            return true;
    }
    return false;
}
Also used : ThreeState(com.intellij.util.ThreeState) VcsException(com.intellij.openapi.vcs.VcsException) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) Date(java.util.Date)

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