Search in sources :

Example 1 with BinaryContentRevision

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

the class IdeaTextPatchBuilder method convertRevisionToAir.

@Nullable
private static AirContentRevision convertRevisionToAir(final ContentRevision cr, final Long ts) {
    if (cr == null)
        return null;
    final FilePath fp = cr.getFile();
    final StaticPathDescription description = new StaticPathDescription(fp.isDirectory(), ts == null ? fp.getIOFile().lastModified() : ts, fp.getPath());
    if (cr instanceof BinaryContentRevision) {
        return new BinaryAirContentRevision((BinaryContentRevision) cr, description, ts);
    } else {
        return new TextAirContentRevision(cr, description, ts);
    }
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) BinaryContentRevision(com.intellij.openapi.vcs.changes.BinaryContentRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with BinaryContentRevision

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

the class DiffActionExecutor method createRemote.

@Nullable
protected DiffContent createRemote(final VcsRevisionNumber revisionNumber) throws IOException, VcsException {
    final ContentRevision fileRevision = myDiffProvider.createFileContent(revisionNumber, mySelectedFile);
    if (fileRevision == null)
        return null;
    DiffContentFactoryEx contentFactory = DiffContentFactoryEx.getInstanceEx();
    DiffContent diffContent;
    if (fileRevision instanceof BinaryContentRevision) {
        FilePath filePath = fileRevision.getFile();
        final byte[] content = ((BinaryContentRevision) fileRevision).getBinaryContent();
        if (content == null)
            return null;
        diffContent = contentFactory.createBinary(myProject, content, filePath.getFileType(), filePath.getName());
    } else if (fileRevision instanceof ByteBackedContentRevision) {
        byte[] content = ((ByteBackedContentRevision) fileRevision).getContentAsBytes();
        if (content == null)
            throw new VcsException("Failed to load content");
        diffContent = contentFactory.createFromBytes(myProject, content, fileRevision.getFile());
    } else {
        String content = fileRevision.getContent();
        if (content == null)
            throw new VcsException("Failed to load content");
        diffContent = contentFactory.create(myProject, content, fileRevision.getFile());
    }
    diffContent.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(fileRevision.getFile(), fileRevision.getRevisionNumber()));
    return diffContent;
}
Also used : BinaryContentRevision(com.intellij.openapi.vcs.changes.BinaryContentRevision) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) ByteBackedContentRevision(com.intellij.openapi.vcs.changes.ByteBackedContentRevision) BinaryContentRevision(com.intellij.openapi.vcs.changes.BinaryContentRevision) DiffContentFactoryEx(com.intellij.diff.DiffContentFactoryEx) DiffContent(com.intellij.diff.contents.DiffContent) ByteBackedContentRevision(com.intellij.openapi.vcs.changes.ByteBackedContentRevision) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

BinaryContentRevision (com.intellij.openapi.vcs.changes.BinaryContentRevision)2 Nullable (org.jetbrains.annotations.Nullable)2 DiffContentFactoryEx (com.intellij.diff.DiffContentFactoryEx)1 DiffContent (com.intellij.diff.contents.DiffContent)1 FilePath (com.intellij.openapi.vcs.FilePath)1 ByteBackedContentRevision (com.intellij.openapi.vcs.changes.ByteBackedContentRevision)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1