Search in sources :

Example 1 with ShelvedBinaryContentRevision

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

the class ApplyBinaryShelvedFilePatch method applyChange.

protected Result applyChange(Project project, final VirtualFile fileToPatch, FilePath pathBeforeRename, Getter<CharSequence> baseContents) throws IOException {
    try {
        ContentRevision contentRevision = myPatch.getShelvedBinaryFile().createChange(project).getAfterRevision();
        if (contentRevision != null) {
            assert (contentRevision instanceof ShelvedBinaryContentRevision);
            byte[] binaryContent = ((ShelvedBinaryContentRevision) contentRevision).getBinaryContent();
            //it may be new empty binary file
            fileToPatch.setBinaryContent(binaryContent != null ? binaryContent : ArrayUtil.EMPTY_BYTE_ARRAY);
        }
    } catch (VcsException e) {
        LOG.error("Couldn't apply shelved binary patch", e);
        return new Result(ApplyPatchStatus.FAILURE) {

            @Override
            public ApplyPatchForBaseRevisionTexts getMergeData() {
                return null;
            }
        };
    }
    return SUCCESS;
}
Also used : ShelvedBinaryContentRevision(com.intellij.openapi.vcs.changes.shelf.ShelvedBinaryContentRevision) VcsException(com.intellij.openapi.vcs.VcsException) ShelvedBinaryContentRevision(com.intellij.openapi.vcs.changes.shelf.ShelvedBinaryContentRevision) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) ApplyPatchForBaseRevisionTexts(com.intellij.openapi.vcs.changes.patch.ApplyPatchForBaseRevisionTexts)

Aggregations

VcsException (com.intellij.openapi.vcs.VcsException)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 ApplyPatchForBaseRevisionTexts (com.intellij.openapi.vcs.changes.patch.ApplyPatchForBaseRevisionTexts)1 ShelvedBinaryContentRevision (com.intellij.openapi.vcs.changes.shelf.ShelvedBinaryContentRevision)1