Search in sources :

Example 16 with VcsFileRevision

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

the class FileAnnotation method createDefaultCurrentFileRevisionProvider.

@Nullable
private static CurrentFileRevisionProvider createDefaultCurrentFileRevisionProvider(@NotNull FileAnnotation annotation) {
    List<VcsFileRevision> revisions = annotation.getRevisions();
    if (revisions == null)
        return null;
    Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<>();
    for (VcsFileRevision revision : revisions) {
        map.put(revision.getRevisionNumber(), revision);
    }
    List<VcsFileRevision> lineToRevision = new ArrayList<>(annotation.getLineCount());
    for (int i = 0; i < annotation.getLineCount(); i++) {
        lineToRevision.add(map.get(annotation.getLineRevisionNumber(i)));
    }
    return (lineNumber) -> {
        LOG.assertTrue(lineNumber >= 0 && lineNumber < lineToRevision.size());
        return lineToRevision.get(lineNumber);
    };
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) java.util(java.util) VirtualFile(com.intellij.openapi.vfs.VirtualFile) HashMap(com.intellij.util.containers.HashMap) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) VcsKey(com.intellij.openapi.vcs.VcsKey) ContainerUtil(com.intellij.util.containers.ContainerUtil) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) Nullable(org.jetbrains.annotations.Nullable) DiffProvider(com.intellij.openapi.vcs.diff.DiffProvider) Project(com.intellij.openapi.project.Project) Logger(com.intellij.openapi.diagnostic.Logger) NotNull(org.jetbrains.annotations.NotNull) UpToDateLineNumberProvider(com.intellij.openapi.localVcs.UpToDateLineNumberProvider) Consumer(com.intellij.util.Consumer) HashMap(com.intellij.util.containers.HashMap) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with VcsFileRevision

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

the class AnnotateRevisionAction method getFileRevision.

@Nullable
@Override
protected VcsFileRevision getFileRevision(@NotNull AnActionEvent e) {
    VcsHistorySession historySession = e.getData(VcsDataKeys.HISTORY_SESSION);
    if (historySession == null)
        return null;
    VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
    if (!historySession.isContentAvailable(revision))
        return null;
    return revision;
}
Also used : VcsHistorySession(com.intellij.openapi.vcs.history.VcsHistorySession) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with VcsFileRevision

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

the class GetVersionAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
    VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
    if (e.getProject() == null || filePath == null || revision == null) {
        e.getPresentation().setEnabledAndVisible(false);
    } else {
        e.getPresentation().setEnabledAndVisible(isContentAvailable(filePath, revision, e));
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Example 19 with VcsFileRevision

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

the class GetVersionAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    if (ChangeListManager.getInstance(project).isFreezedWithNotification(null))
        return;
    VcsFileRevision revision = e.getRequiredData(VcsDataKeys.VCS_FILE_REVISION);
    FilePath filePath = e.getRequiredData(VcsDataKeys.FILE_PATH);
    doGet(project, revision, filePath);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) Project(com.intellij.openapi.project.Project) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision)

Example 20 with VcsFileRevision

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

the class ShowDiffWithLocalFromHistoryAction method performAction.

@Override
protected void performAction(@NotNull Project project, @NotNull FileHistoryUi ui, @NotNull VcsFullCommitDetails detail, @NotNull AnActionEvent e) {
    if (ChangeListManager.getInstance(project).isFreezedWithNotification(null))
        return;
    FilePath path = e.getRequiredData(VcsDataKeys.FILE_PATH);
    VcsFileRevision revision = ui.createRevision(detail);
    if (revision != null) {
        StandardDiffFromHistoryHandler handler = new StandardDiffFromHistoryHandler();
        handler.showDiffForTwo(project, path, revision, new CurrentRevision(notNull(path.getVirtualFile()), VcsRevisionNumber.NULL));
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) StandardDiffFromHistoryHandler(com.intellij.openapi.vcs.history.StandardDiffFromHistoryHandler) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) CurrentRevision(com.intellij.openapi.vcs.history.CurrentRevision)

Aggregations

VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 Nullable (org.jetbrains.annotations.Nullable)13 FilePath (com.intellij.openapi.vcs.FilePath)12 Project (com.intellij.openapi.project.Project)10 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)8 VcsHistorySession (com.intellij.openapi.vcs.history.VcsHistorySession)7 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)7 VcsKey (com.intellij.openapi.vcs.VcsKey)5 VcsAbstractHistorySession (com.intellij.openapi.vcs.history.VcsAbstractHistorySession)5 VcsAppendableHistorySessionPartner (com.intellij.openapi.vcs.history.VcsAppendableHistorySessionPartner)5 Semaphore (com.intellij.util.concurrency.Semaphore)5 GitFileRevision (git4idea.GitFileRevision)5 Test (org.junit.Test)5 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)4 NotNull (org.jetbrains.annotations.NotNull)4 Annotation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)3 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)3 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)3 HashMap (com.intellij.util.containers.HashMap)3