コード例 #1
0
  public static boolean isBinaryChange(Change change) {
    if (change.hasOtherLayers()) return false; // +-
    final ContentRevision bRev = change.getBeforeRevision();
    final ContentRevision aRev = change.getAfterRevision();

    return (aRev == null || aRev instanceof BinaryContentRevision)
        && (bRev == null || bRev instanceof BinaryContentRevision);
  }
コード例 #2
0
 public static BeforeAfter<DiffContent> createBinaryDiffContents(
     final Project project, final Change change) throws VcsException {
   final FilePath filePath = ChangesUtil.getFilePath(change);
   try {
     return new BeforeAfter<DiffContent>(
         createBinaryFileContent(project, change.getBeforeRevision(), filePath.getName()),
         createBinaryFileContent(project, change.getAfterRevision(), filePath.getName()));
   } catch (IOException e) {
     throw new VcsException(e);
   }
 }
コード例 #3
0
 private static SimpleDiffRequest createBinaryDiffRequest(
     final Project project, final Change change) throws VcsException {
   final FilePath filePath = ChangesUtil.getFilePath(change);
   final SimpleDiffRequest request = new SimpleDiffRequest(project, filePath.getPath());
   try {
     request.setContents(
         createBinaryFileContent(project, change.getBeforeRevision(), filePath.getName()),
         createBinaryFileContent(project, change.getAfterRevision(), filePath.getName()));
     return request;
   } catch (IOException e) {
     throw new VcsException(e);
   }
 }
コード例 #4
0
 private boolean checkIfThereAreFakeRevisions(final Project project, final Change[] changes) {
   boolean needsConvertion = false;
   for (Change change : changes) {
     final ContentRevision beforeRevision = change.getBeforeRevision();
     final ContentRevision afterRevision = change.getAfterRevision();
     if (beforeRevision instanceof FakeRevision) {
       VcsDirtyScopeManager.getInstance(project).fileDirty(beforeRevision.getFile());
       needsConvertion = true;
     }
     if (afterRevision instanceof FakeRevision) {
       VcsDirtyScopeManager.getInstance(project).fileDirty(afterRevision.getFile());
       needsConvertion = true;
     }
   }
   return needsConvertion;
 }
コード例 #5
0
 private static boolean checkNotifyBinaryDiff(final Change selectedChange) {
   final ContentRevision beforeRevision = selectedChange.getBeforeRevision();
   final ContentRevision afterRevision = selectedChange.getAfterRevision();
   if (beforeRevision instanceof BinaryContentRevision
       && afterRevision instanceof BinaryContentRevision) {
     try {
       byte[] beforeContent = ((BinaryContentRevision) beforeRevision).getBinaryContent();
       byte[] afterContent = ((BinaryContentRevision) afterRevision).getBinaryContent();
       if (Arrays.equals(beforeContent, afterContent)) {
         Messages.showInfoMessage(
             VcsBundle.message("message.text.binary.versions.are.identical"),
             VcsBundle.message("message.title.diff"));
       } else {
         Messages.showInfoMessage(
             VcsBundle.message("message.text.binary.versions.are.different"),
             VcsBundle.message("message.title.diff"));
       }
     } catch (VcsException e) {
       Messages.showInfoMessage(e.getMessage(), VcsBundle.message("message.title.diff"));
     }
     return true;
   }
   return false;
 }