From 2479143fac9388a807a29650de2ac9760f6aa9e4 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Sun, 17 Aug 2014 00:38:16 +0400 Subject: [PATCH] vcs: changes cache: Ensure each "Update Info" panel shows only change lists changed during update it reflects - make each panel use separate Consumer for getting necessary change lists (instead of subscribing to Topic in project message bus) --- .../committed/CommittedChangesCache.java | 23 ++++++++++++++----- .../update/AbstractCommonUpdateAction.java | 23 +++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java index 4e283afb6b78..6619b98ea5e9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java @@ -44,6 +44,7 @@ import com.intellij.util.Consumer; import com.intellij.util.MessageBusUtil; import com.intellij.util.NotNullFunction; import com.intellij.util.containers.ConcurrentHashMap; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; @@ -772,6 +773,11 @@ public class CommittedChangesCache implements PersistentStateComponent> incomingChangesConsumer) { final Runnable task = new Runnable() { @Override public void run() { @@ -781,7 +787,7 @@ public class CommittedChangesCache implements PersistentStateComponent> incomingChangesConsumer) { myPendingUpdateCount--; if (myPendingUpdateCount == 0) { notifyIncomingChangesUpdated(myNewIncomingChanges); + if (incomingChangesConsumer != null) { + incomingChangesConsumer.consume(ContainerUtil.newArrayList(myNewIncomingChanges)); + } myNewIncomingChanges.clear(); } } - private void processUpdatedFilesAfterRefresh(final ChangesCacheFile cache, final UpdatedFiles updatedFiles) { + private void processUpdatedFilesAfterRefresh(final ChangesCacheFile cache, + final UpdatedFiles updatedFiles, + @Nullable final Consumer> incomingChangesConsumer) { refreshCacheAsync(cache, false, new RefreshResultConsumer() { @Override public void receivedChanges(final List committedChangeLists) { @@ -833,7 +844,7 @@ public class CommittedChangesCache implements PersistentStateComponent>() { + @Override + public void consume(List incomingChangeLists) { + tree.setChangeLists(incomingChangeLists); + } + }); if (someSessionWasCancelled) { VcsBalloonProblemNotifier.showOverChangesView(myProject, "VCS Update Incomplete" + prepareNotificationWithUpdateInfo(), MessageType.WARNING); @@ -592,7 +596,8 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction { } } - private void showUpdateTree(final boolean willBeContinued, final boolean wasCanceled) { + @NotNull + private UpdateInfoTree showUpdateTree(final boolean willBeContinued, final boolean wasCanceled) { RestoreUpdateTree restoreUpdateTree = RestoreUpdateTree.getInstance(myProject); restoreUpdateTree.registerUpdateInformation(myUpdatedFiles, myActionInfo); final String text = getTemplatePresentation().getText() + ((willBeContinued || (myUpdateNumber > 1)) ? ("#" + myUpdateNumber) : ""); @@ -602,13 +607,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction { updateInfoTree.setAfter(myAfter); updateInfoTree.setCanGroupByChangeList(canGroupByChangelist(myVcsToVirtualFiles.keySet())); - myProject.getMessageBus().connect(updateInfoTree).subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() { - public void incomingChangesUpdated(final List receivedChanges) { - if (receivedChanges != null) { - updateInfoTree.setChangeLists(receivedChanges); - } - } - }); + return updateInfoTree; } public void onCancel() {