Search in sources :

Example 26 with AbstractVcs

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

the class UpdateOperation method fileIsUnderProject.

@Override
public boolean fileIsUnderProject(File file) {
    final FilePath path = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file);
    if (!super.fileIsUnderProject(file)) {
        return false;
    }
    final AbstractVcs vcs = ApplicationManager.getApplication().runReadAction(new Computable<AbstractVcs>() {

        @Nullable
        public AbstractVcs compute() {
            return myVcsManager.getVcsFor(path);
        }
    });
    return vcs == myVcs;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) Nullable(org.jetbrains.annotations.Nullable)

Example 27 with AbstractVcs

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

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

Example 29 with AbstractVcs

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

the class CompareWithSelectedRevisionAction method actionPerformed.

@Override
protected void actionPerformed(@NotNull VcsContext vcsContext) {
    final VirtualFile file = vcsContext.getSelectedFiles()[0];
    final Project project = vcsContext.getProject();
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    final VcsHistoryProvider vcsHistoryProvider = vcs.getVcsHistoryProvider();
    new VcsHistoryProviderBackgroundableProxy(vcs, vcsHistoryProvider, vcs.getDiffProvider()).createSessionFor(vcs.getKeyInstanceMethod(), VcsUtil.getFilePath(file), new Consumer<VcsHistorySession>() {

        @Override
        public void consume(VcsHistorySession session) {
            if (session == null)
                return;
            final List<VcsFileRevision> revisions = session.getRevisionList();
            final HistoryAsTreeProvider treeHistoryProvider = session.getHistoryAsTreeProvider();
            if (treeHistoryProvider != null) {
                showTreePopup(treeHistoryProvider.createTreeOn(revisions), file, project, vcs.getDiffProvider());
            } else {
                showListPopup(revisions, project, new Consumer<VcsFileRevision>() {

                    @Override
                    public void consume(final VcsFileRevision revision) {
                        DiffActionExecutor.showDiff(vcs.getDiffProvider(), revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH);
                    }
                }, true);
            }
        }
    }, VcsBackgroundableActions.COMPARE_WITH, false, null);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Consumer(com.intellij.util.Consumer) List(java.util.List) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 30 with AbstractVcs

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

the class SelectAndCompareWithSelectedRevisionAction method actionPerformed.

@Override
protected void actionPerformed(@NotNull VcsContext vcsContext) {
    final VirtualFile file = vcsContext.getSelectedFiles()[0];
    final Project project = vcsContext.getProject();
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    if (vcs == null) {
        return;
    }
    RevisionSelector selector = vcs.getRevisionSelector();
    final DiffProvider diffProvider = vcs.getDiffProvider();
    if (selector != null) {
        final VcsRevisionNumber vcsRevisionNumber = selector.selectNumber(file);
        if (vcsRevisionNumber != null) {
            DiffActionExecutor.showDiff(diffProvider, vcsRevisionNumber, file, project, VcsBackgroundableActions.COMPARE_WITH);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DiffProvider(com.intellij.openapi.vcs.diff.DiffProvider) RevisionSelector(com.intellij.openapi.vcs.diff.RevisionSelector) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) 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