From e0cb157cb84ec387aebdbb9a1c75b83b50ef6fe4 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 14 Apr 2011 14:32:03 +0400 Subject: [PATCH] VCS History Diff: don't load file revisions in AWT --- .../vcs/history/FileHistoryPanelImpl.java | 56 +++++++++++-------- .../openapi/vcs/history/VcsHistoryUtil.java | 9 ++- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 6c757de2e853..d29965f7310a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -609,30 +609,40 @@ public class FileHistoryPanelImpl 0) { - left = revision2; - right = revision1; - } - - try { - final String leftTitle = left.getRevisionNumber().asString() + (left instanceof CurrentRevision ? " (" + VcsBundle.message("diff.title.local") + ")" : ""); - final String rightTitle = right.getRevisionNumber().asString() + (right instanceof CurrentRevision ? " (" + VcsBundle.message("diff.title.local") + ")" : ""); - VcsHistoryUtil.showDiff(project, myFilePath, left, right, leftTitle, rightTitle); - } catch (final VcsException e) { - WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { - public void run() { - Messages.showErrorDialog(VcsBundle.message("message.text.cannot.show.differences", e.getLocalizedMessage()), - VcsBundle.message("message.title.show.differences")); + private void showDifferences(final Project project, final VcsFileRevision revision1, final VcsFileRevision revision2) { + new Task.Backgroundable(project, "Loading revisions to compare") { + @Override + public void run(@NotNull ProgressIndicator indicator) { + VcsFileRevision left = revision1; + VcsFileRevision right = revision2; + if (VcsHistoryUtil.compare(revision1, revision2) > 0) { + left = revision2; + right = revision1; } - }, null, project); - } catch (IOException e) { - LOG.error(e); - } catch (ProcessCanceledException ex) { - LOG.info(ex); - } + + try { + final String leftTitle = left.getRevisionNumber().asString() + + (left instanceof CurrentRevision ? " (" + VcsBundle.message("diff.title.local") + ")" : ""); + final String rightTitle = right.getRevisionNumber().asString() + + (right instanceof CurrentRevision ? " (" + VcsBundle.message("diff.title.local") + ")" : ""); + VcsHistoryUtil.showDiff(project, myFilePath, left, right, leftTitle, rightTitle); + } + catch (final VcsException e) { + WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { + public void run() { + Messages.showErrorDialog(VcsBundle.message("message.text.cannot.show.differences", e.getLocalizedMessage()), + VcsBundle.message("message.title.show.differences")); + } + }, null, project); + } + catch (IOException e) { + LOG.error(e); + } + catch (ProcessCanceledException ex) { + LOG.info(ex); + } + } + }.queue(); } protected JComponent createCenterPanel() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java index f9d9efad3380..d886b0d1e879 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java @@ -25,6 +25,7 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingManager; import com.intellij.openapi.vfs.encoding.EncodingProjectManager; +import com.intellij.util.WaitForProgressToShow; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -80,10 +81,14 @@ public class VcsHistoryUtil { diffData.setContentTitles(title1, title2); diffData.setContents(createContent(project, content1, revision1, doc, charset, fileType), createContent(project, content2, revision2, doc, charset, fileType)); - DiffManager.getInstance().getDiffTool().show(diffData); + WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { + public void run() { + DiffManager.getInstance().getDiffTool().show(diffData); + } + }, null, project); } - public static byte[] loadRevisionContent(VcsFileRevision revision) throws VcsException, IOException { + public static byte[] loadRevisionContent(VcsFileRevision revision) throws VcsException, IOException { byte[] content = revision.getContent(); if (content == null) { revision.loadContent();