vcs: move data from LocalChangeListImpl to the ChangeListWorker

This commit is contained in:
Aleksey Pivovarov
2017-03-02 15:19:15 +03:00
committed by Aleksey Pivovarov
parent 957b72d5d9
commit 306802da69
2 changed files with 8 additions and 20 deletions
@@ -57,6 +57,8 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
private final ChangesDelta myDelta;
private final Set<String> myListsToDisappear;
private final Map<LocalChangeListImpl, OpenTHashSet<Change>> myChangesBeforeUpdateMap = new HashMap<>();
public ChangeListWorker(final Project project, final PlusMinusModify<BaseRevision> deltaListener) {
myProject = project;
myMap = new LinkedHashMap<>();
@@ -237,7 +239,8 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
LOG.debug("[addChangeToCorrespondingList] for change " + path + " type: " + change.getType() + " have before revision: " + (change.getBeforeRevision() != null));
assert myDefault != null;
for (LocalChangeListImpl list : myMap.values()) {
if (list.getChangesBeforeUpdate().contains(change)) {
OpenTHashSet<Change> changesBeforeUpdate = myChangesBeforeUpdateMap.get(list);
if (changesBeforeUpdate.contains(change)) {
LOG.debug("[addChangeToCorrespondingList] matched: " + list.getName());
list.addChange(change);
myIdx.changeAdded(change, vcsKey);
@@ -393,11 +396,13 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
}
}
myListsToDisappear.clear();
myChangesBeforeUpdateMap.clear();
}
private Collection<Change> startProcessingChanges(@NotNull LocalChangeListImpl list, @Nullable final VcsDirtyScope scope) {
OpenTHashSet<Change> changesBeforeUpdate = new OpenTHashSet<>(list.getChanges());
list.setChangesBeforeUpdate(changesBeforeUpdate);
myChangesBeforeUpdateMap.put(list, changesBeforeUpdate);
final Collection<Change> result = new ArrayList<>();
for (Change oldBoy : changesBeforeUpdate) {
@@ -429,7 +434,7 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
}
private boolean doneProcessingChanges(@NotNull LocalChangeListImpl list, List<Change> removedChanges, List<Change> addedChanges) {
OpenTHashSet<Change> changesBeforeUpdate = list.getChangesBeforeUpdate();
OpenTHashSet<Change> changesBeforeUpdate = myChangesBeforeUpdateMap.get(list);
Set<Change> changes = list.getChanges();
boolean changesDetected = (changes.size() != changesBeforeUpdate.size());
@@ -446,8 +451,6 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
removedChanges.addAll(removed);
changesDetected = changesDetected || (!removedChanges.isEmpty());
list.setChangesBeforeUpdate(null);
return changesDetected;
}
@@ -5,11 +5,9 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.OpenTHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
@@ -30,7 +28,6 @@ public class LocalChangeListImpl extends LocalChangeList {
private boolean myIsDefault = false;
private boolean myIsReadOnly = false;
private OpenTHashSet<Change> myChangesBeforeUpdate;
@NotNull
public static LocalChangeListImpl createEmptyChangeListImpl(@NotNull Project project, @NotNull String name, @Nullable String id) {
@@ -57,10 +54,6 @@ public class LocalChangeListImpl extends LocalChangeList {
myChanges = ContainerUtil.newHashSet(origin.myChanges);
if (myChangesBeforeUpdate != null) {
myChangesBeforeUpdate = new OpenTHashSet<>((Collection<Change>)origin.myChangesBeforeUpdate);
}
if (myReadChangesCache != null) {
myReadChangesCache = origin.myReadChangesCache;
}
@@ -156,14 +149,6 @@ public class LocalChangeListImpl extends LocalChangeList {
return null;
}
void setChangesBeforeUpdate(OpenTHashSet<Change> changesBeforeUpdate) {
myChangesBeforeUpdate = changesBeforeUpdate;
}
OpenTHashSet<Change> getChangesBeforeUpdate() {
return myChangesBeforeUpdate;
}
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;