vcs: do not fail to create patch with mixed binary-text FileType
authorAleksey Pivovarov <aleksey.pivovarov@jetbrains.com>
Fri, 2 Sep 2016 09:15:04 +0000 (12:15 +0300)
committerAleksey Pivovarov <aleksey.pivovarov@jetbrains.com>
Fri, 2 Sep 2016 09:15:04 +0000 (12:15 +0300)
platform/vcs-impl/src/com/intellij/openapi/diff/impl/patch/IdeaTextPatchBuilder.java

index c36fcc25a786bd88d73bda83b31311ed4d49a4c4..4bb1bb5c6bdd1b36b0781659e1b3c4e40a4798b1 100644 (file)
@@ -188,7 +188,13 @@ public class IdeaTextPatchBuilder {
     }
 
     public byte[] getContentAsBytes() throws VcsException {
-      throw new IllegalStateException();
+      if (myRevision instanceof ByteBackedContentRevision) {
+        return ((ByteBackedContentRevision)myRevision).getContentAsBytes();
+      }
+
+      String textContent = getContentAsString();
+      if (textContent == null) return null;
+      return textContent.getBytes(getCharset());
     }
 
     public String getRevisionNumber() {