summaryrefslogtreecommitdiff
path: root/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java')
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java25
1 files changed, 18 insertions, 7 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 2da25f6e92c1..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,16 +773,21 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
}
public void processUpdatedFiles(final UpdatedFiles updatedFiles) {
+ processUpdatedFiles(updatedFiles, null);
+ }
+
+ public void processUpdatedFiles(final UpdatedFiles updatedFiles,
+ @Nullable final Consumer<List<CommittedChangeList>> incomingChangesConsumer) {
final Runnable task = new Runnable() {
@Override
public void run() {
debug("Processing updated files");
final Collection<ChangesCacheFile> caches = myCachesHolder.getAllCaches();
+ myPendingUpdateCount += caches.size();
for(final ChangesCacheFile cache: caches) {
- myPendingUpdateCount++;
try {
if (cache.isEmpty()) {
- pendingUpdateProcessed();
+ pendingUpdateProcessed(incomingChangesConsumer);
continue;
}
debug("Processing updated files in " + cache.getLocation());
@@ -789,12 +795,12 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
if (needRefresh) {
debug("Found unaccounted files, requesting refresh");
// todo do we need double-queueing here???
- processUpdatedFilesAfterRefresh(cache, updatedFiles);
+ processUpdatedFilesAfterRefresh(cache, updatedFiles, incomingChangesConsumer);
}
else {
debug("Clearing cached incoming changelists");
myCachedIncomingChangeLists = null;
- pendingUpdateProcessed();
+ pendingUpdateProcessed(incomingChangesConsumer);
}
}
catch (IOException e) {
@@ -806,15 +812,20 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
myTaskQueue.run(task);
}
- private void pendingUpdateProcessed() {
+ private void pendingUpdateProcessed(@Nullable Consumer<List<CommittedChangeList>> 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<List<CommittedChangeList>> incomingChangesConsumer) {
refreshCacheAsync(cache, false, new RefreshResultConsumer() {
@Override
public void receivedChanges(final List<CommittedChangeList> committedChangeLists) {
@@ -833,7 +844,7 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
debug("Clearing cached incoming changelists");
myCachedIncomingChangeLists = null;
}
- pendingUpdateProcessed();
+ pendingUpdateProcessed(incomingChangesConsumer);
}
catch (IOException e) {
LOG.error(e);