From be912421b52b4eeddcdeaed655433ab1ef802796 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Sat, 2 Apr 2011 15:46:19 +0200 Subject: [PATCH] do not run Mercurial commands in EDT (seen in PY-3254) --- .../hg4idea/HgCurrentBranchStatusUpdater.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgCurrentBranchStatusUpdater.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgCurrentBranchStatusUpdater.java index aef14aedcc21..1c729206d11d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgCurrentBranchStatusUpdater.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgCurrentBranchStatusUpdater.java @@ -12,6 +12,7 @@ // limitations under the License. package org.zmlx.hg4idea; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.FileDocumentManager; @@ -34,18 +35,28 @@ class HgCurrentBranchStatusUpdater implements HgUpdater { this.hgCurrentBranchStatus = hgCurrentBranchStatus; } - public void update(Project project) { + public void update(final Project project) { Editor textEditor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (textEditor != null) { Document document = textEditor.getDocument(); VirtualFile file = FileDocumentManager.getInstance().getFile(document); - VirtualFile repo = VcsUtil.getVcsRootFor(project, file); + final VirtualFile repo = VcsUtil.getVcsRootFor(project, file); if (repo != null) { - HgTagBranchCommand hgTagBranchCommand = new HgTagBranchCommand(project, repo); - String branch = hgTagBranchCommand.getCurrentBranch(); - List parents = new HgWorkingCopyRevisionsCommand(project).parents(repo); - hgCurrentBranchStatus.updateFor(branch, parents); + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + HgTagBranchCommand hgTagBranchCommand = new HgTagBranchCommand(project, repo); + final String branch = hgTagBranchCommand.getCurrentBranch(); + final List parents = new HgWorkingCopyRevisionsCommand(project).parents(repo); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + hgCurrentBranchStatus.updateFor(branch, parents); + } + }); + } + }); return; } }