Don't suspend VcsDirtyScopeManager: prefer suspending the ChangeListManager

This commit is contained in:
Kirill Likhodedov
2015-08-08 14:55:42 +03:00
parent fa3e2cd048
commit c84760e360
2 changed files with 10 additions and 53 deletions
@@ -91,24 +91,6 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
}
}
public void suspendMe() {
myLife.suspendMe();
}
public void reanimate() {
final Ref<Boolean> wasNotEmptyRef = new Ref<Boolean>();
myLife.releaseMe(new Runnable() {
@Override
public void run() {
wasNotEmptyRef.set(! myDirtBuilder.isEmpty());
}
});
if (Boolean.TRUE.equals(wasNotEmptyRef.get())) {
myChangeListManager.scheduleUpdate();
}
}
@Override
public void markEverythingDirty() {
if ((! myProject.isOpen()) || myProject.isDisposed() || myVcsManager.getAllActiveVcss().length == 0) return;
@@ -123,7 +105,7 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
}
});
if (lifeDrop.isDone() && !lifeDrop.isSuspened()) {
if (lifeDrop.isDone()) {
myChangeListManager.scheduleUpdate();
}
}
@@ -218,7 +200,7 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
};
final LifeDrop lifeDrop = myLife.doIfAlive(runnable);
if (lifeDrop.isDone() && !lifeDrop.isSuspened() && Boolean.TRUE.equals(wasNotEmptyRef.get())) {
if (lifeDrop.isDone() && Boolean.TRUE.equals(wasNotEmptyRef.get())) {
myChangeListManager.scheduleUpdate();
}
}
@@ -459,26 +441,19 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
private static class LifeDrop {
private final boolean myDone;
private final boolean mySuspened;
private LifeDrop(boolean done, boolean suspened) {
private LifeDrop(boolean done) {
myDone = done;
mySuspened = suspened;
}
public boolean isDone() {
return myDone;
}
public boolean isSuspened() {
return mySuspened;
}
}
private static class SynchronizedLife {
private LifeStages myStage;
private final Object myLock;
private boolean mySuspended;
private SynchronizedLife() {
myStage = LifeStages.NOT_BORN;
@@ -498,31 +473,14 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
}
}
public void suspendMe() {
synchronized (myLock) {
if (LifeStages.ALIVE.equals(myStage)) {
mySuspended = true;
}
}
}
public void releaseMe(final Runnable runnable) {
synchronized (myLock) {
if (LifeStages.ALIVE.equals(myStage)) {
mySuspended = false;
runnable.run();
}
}
}
// allow work under inner lock: inner class, not wide scope
public LifeDrop doIfAlive(final Runnable runnable) {
synchronized (myLock) {
if (LifeStages.ALIVE.equals(myStage)) {
runnable.run();
return new LifeDrop(true, mySuspended);
return new LifeDrop(true);
}
return new LifeDrop(false, mySuspended);
return new LifeDrop(false);
}
}
@@ -34,10 +34,7 @@ import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.actions.AbstractVcsAction;
import com.intellij.openapi.vcs.actions.DescindingFilesFilter;
import com.intellij.openapi.vcs.actions.VcsContext;
import com.intellij.openapi.vcs.changes.RemoteRevisionsCache;
import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManagerImpl;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
@@ -293,6 +290,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
private final Project myProject;
private final ProjectLevelVcsManagerEx myProjectLevelVcsManager;
private final ChangeListManagerEx myChangeListManager;
private UpdatedFiles myUpdatedFiles;
private final FilePath[] myRoots;
private final Map<AbstractVcs, Collection<FilePath>> myVcsToVirtualFiles;
@@ -313,6 +311,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
myProject = project;
myProjectLevelVcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myChangeListManager = (ChangeListManagerEx)ChangeListManager.getInstance(myProject);
myRoots = roots;
myVcsToVirtualFiles = vcsToVirtualFiles;
@@ -335,14 +334,14 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
private void suspendIfNeeded() {
if (! myActionInfo.canChangeFileStatus()) {
// i.e. for update but not for integrate or status
((VcsDirtyScopeManagerImpl) myDirtyScopeManager).suspendMe();
myChangeListManager.freezeImmediately(null);
}
}
private void releaseIfNeeded() {
if (! myActionInfo.canChangeFileStatus()) {
// i.e. for update but not for integrate or status
((VcsDirtyScopeManagerImpl) myDirtyScopeManager).reanimate();
myChangeListManager.letGo();
}
}