use of com.intellij.openapi.vcs.changes.ByteBackedContentRevision 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;
}
Aggregations