IDEA-76795 vcs: do not allow multiple processes to load same committed change details

This commit is contained in:
Aleksey Pivovarov
2015-12-03 14:23:38 +03:00
parent ac0541ff6c
commit d167e3d491
2 changed files with 14 additions and 1 deletions
@@ -669,6 +669,12 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
final CommittedChangeList[] list = new CommittedChangeList[1];
final FilePath[] targetPath = new FilePath[1];
final VcsException[] exc = new VcsException[1];
final BackgroundableActionLock lock = BackgroundableActionLock.getLock(project, VcsBackgroundableActions.COMMITTED_CHANGES_DETAILS,
revision, virtualFile.getPath());
if (lock.isLocked()) return;
lock.lock();
Task.Backgroundable task = new Task.Backgroundable(project, title, true, BackgroundFromStartOption.getInstance()) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
@@ -700,8 +706,14 @@ public class AbstractVcsHelperImpl extends AbstractVcsHelper {
}
}
@Override
public void onCancel() {
lock.unlock();
}
@Override
public void onSuccess() {
lock.unlock();
if (exc[0] != null) {
showError(exc[0], failedText(virtualFile, revision));
}
@@ -22,7 +22,8 @@ public enum VcsBackgroundableActions {
ANNOTATE,
COMPARE_WITH, // common for compare with (selected/latest/same) revision
CREATE_HISTORY_SESSION,
HISTORY_FOR_SELECTION;
HISTORY_FOR_SELECTION,
COMMITTED_CHANGES_DETAILS;
public static Object keyFrom(final FilePath filePath) {
return filePath.getPath();