public static void showDiffImpl(
      final Project project,
      @NotNull List<DiffRequestPresentable> changeList,
      int index,
      @NotNull final ShowDiffUIContext context) {
    final ChangeDiffRequest request =
        new ChangeDiffRequest(
            project, changeList, context.getActionsFactory(), context.isShowFrame());
    final DiffTool tool = DiffManager.getInstance().getDiffTool();
    final DiffRequest simpleRequest;
    try {
      request.quickCheckHaveStuff();
      simpleRequest = request.init(index);
    } catch (VcsException e) {
      Messages.showWarningDialog(e.getMessage(), "Show Diff");
      return;
    }

    if (simpleRequest != null) {
      final DiffNavigationContext navigationContext = context.getDiffNavigationContext();
      if (navigationContext != null) {
        simpleRequest.passForDataContext(DiffTool.SCROLL_TO_LINE, navigationContext);
      }
      tool.show(simpleRequest);
    }
  }
 private static void showBinaryDiff(Project project, Change change) {
   try {
     final SimpleDiffRequest request = createBinaryDiffRequest(project, change);
     if (DiffManager.getInstance().getDiffTool().canShow(request)) {
       DiffManager.getInstance().getDiffTool().show(request);
     }
   } catch (VcsException e) {
     Messages.showWarningDialog(e.getMessage(), "Show Diff");
   }
 }
Ejemplo n.º 3
0
    @Override
    public void run(final ContinuationContext context) {
      final MultiMap<String, Change> map = myIntersection.getChangesSubset();

      final RefreshSessionImpl session =
          new RefreshSessionImpl(
              true,
              false,
              new Runnable() {
                public void run() {
                  context.ping();
                }
              });

      for (String name : map.keySet()) {
        try {
          final Collection<Change> changes = map.get(name);
          ApplicationManager.getApplication()
              .invokeAndWait(
                  new Runnable() {
                    @Override
                    public void run() {
                      FileDocumentManager.getInstance().saveAllDocuments();
                    }
                  },
                  ModalityState.NON_MODAL);
          ShelveChangesManager.getInstance(myProject)
              .shelveChanges(
                  changes, myIntersection.getComment(name) + " (auto shelve before merge)", true);
          session.addAllFiles(ChangesUtil.getFilesFromChanges(changes));
        } catch (IOException e) {
          finishWithError(context, e.getMessage(), true);
        } catch (VcsException e) {
          finishWithError(context, e.getMessage(), true);
        }
      }
      // first suspend to guarantee stop->then start back sequence
      context.suspend();
      session.launch();
    }
 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;
 }