mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CVS: local changes update should not delay Project closing. extra canceled() checks (corrected)
This commit is contained in:
+27
-19
@@ -38,7 +38,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -87,30 +86,37 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Processing changes for scope " + dirtyScope);
|
||||
}
|
||||
final Runnable checkCanceled = new Runnable() {
|
||||
public void run() {
|
||||
if (progress != null) {
|
||||
progress.checkCanceled();
|
||||
}
|
||||
}
|
||||
};
|
||||
for (FilePath path : dirtyScope.getRecursivelyDirtyDirectories()) {
|
||||
final VirtualFile dir = path.getVirtualFile();
|
||||
ProgressManager.checkCanceled();
|
||||
checkCanceled.run();
|
||||
if (dir != null) {
|
||||
processEntriesIn(dir, dirtyScope, builder, true);
|
||||
processEntriesIn(dir, dirtyScope, builder, true, checkCanceled);
|
||||
}
|
||||
else {
|
||||
processFile(path, builder);
|
||||
processFile(path, builder, checkCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
for (FilePath path : dirtyScope.getDirtyFiles()) {
|
||||
ProgressManager.checkCanceled();
|
||||
checkCanceled.run();
|
||||
if (path.isDirectory()) {
|
||||
final VirtualFile dir = path.getVirtualFile();
|
||||
if (dir != null) {
|
||||
processEntriesIn(dir, dirtyScope, builder, false);
|
||||
processEntriesIn(dir, dirtyScope, builder, false, checkCanceled);
|
||||
}
|
||||
else {
|
||||
processFile(path, builder);
|
||||
processFile(path, builder, checkCanceled);
|
||||
}
|
||||
}
|
||||
else {
|
||||
processFile(path, builder);
|
||||
processFile(path, builder, checkCanceled);
|
||||
}
|
||||
}
|
||||
if (LOG.isDebugEnabled()) {
|
||||
@@ -125,7 +131,8 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
public void doCleanup(final List<VirtualFile> files) {
|
||||
}
|
||||
|
||||
private void processEntriesIn(@NotNull VirtualFile dir, VcsDirtyScope scope, ChangelistBuilder builder, boolean recursively) {
|
||||
private void processEntriesIn(@NotNull VirtualFile dir, VcsDirtyScope scope, ChangelistBuilder builder, boolean recursively,
|
||||
final Runnable checkCanceled) {
|
||||
final FilePath path = VcsContextFactory.SERVICE.getInstance().createFilePathOn(dir);
|
||||
if (!scope.belongsTo(path)) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
@@ -133,7 +140,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
}
|
||||
return;
|
||||
}
|
||||
final DirectoryContent dirContent = getDirectoryContent(dir);
|
||||
final DirectoryContent dirContent = getDirectoryContent(dir, checkCanceled);
|
||||
|
||||
for (VirtualFile file : dirContent.getUnknownFiles()) {
|
||||
builder.processUnversionedFile(file);
|
||||
@@ -165,7 +172,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
builder.processChange(new Change(CurrentContentRevision.create(path), CurrentContentRevision.create(path), FileStatus.DELETED), CvsVcs2.getKey());
|
||||
}
|
||||
for (VirtualFileEntry fileEntry : dirContent.getFiles()) {
|
||||
processFile(dir, fileEntry.getVirtualFile(), fileEntry.getEntry(), builder);
|
||||
processFile(dir, fileEntry.getVirtualFile(), fileEntry.getEntry(), builder, checkCanceled);
|
||||
}
|
||||
|
||||
if (recursively) {
|
||||
@@ -175,7 +182,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
if (file.isDirectory()) {
|
||||
final boolean isIgnored = myFileIndex.isIgnored(file);
|
||||
if (!isIgnored) {
|
||||
processEntriesIn(file, scope, builder, true);
|
||||
processEntriesIn(file, scope, builder, true, checkCanceled);
|
||||
}
|
||||
else {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
@@ -198,8 +205,8 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
|
||||
private void processFile(final FilePath filePath, final ChangelistBuilder builder) {
|
||||
ProgressManager.checkCanceled();
|
||||
private void processFile(final FilePath filePath, final ChangelistBuilder builder, final Runnable checkCanceled) {
|
||||
checkCanceled.run();
|
||||
final VirtualFile dir = filePath.getVirtualFileParent();
|
||||
if (dir == null) return;
|
||||
|
||||
@@ -210,8 +217,9 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
checkSwitchedFile(filePath, builder, dir, entry);
|
||||
}
|
||||
|
||||
private void processFile(final VirtualFile dir, @Nullable VirtualFile file, Entry entry, final ChangelistBuilder builder) {
|
||||
ProgressManager.checkCanceled();
|
||||
private void processFile(final VirtualFile dir, @Nullable VirtualFile file, Entry entry, final ChangelistBuilder builder,
|
||||
final Runnable checkCanceled) {
|
||||
checkCanceled.run();
|
||||
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(dir, entry.getFileName());
|
||||
final FileStatus status = CvsStatusProvider.getStatus(file, entry);
|
||||
final VcsRevisionNumber number = createRevisionNumber(entry.getRevision(), status);
|
||||
@@ -423,7 +431,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
return file == null || !FileTypeManager.getInstance().isFileIgnored(file.getName());
|
||||
}
|
||||
|
||||
private static DirectoryContent getDirectoryContent(VirtualFile directory) {
|
||||
private static DirectoryContent getDirectoryContent(VirtualFile directory, final Runnable checkCanceled) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Retrieving directory content for " + directory);
|
||||
}
|
||||
@@ -441,7 +449,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
for (final Entry entry : entries) {
|
||||
ProgressManager.checkCanceled();
|
||||
checkCanceled.run();
|
||||
String fileName = entry.getFileName();
|
||||
if (entry.isDirectory()) {
|
||||
if (nameToFileMap.containsKey(fileName)) {
|
||||
@@ -469,7 +477,7 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
for (final String name : nameToFileMap.keySet()) {
|
||||
ProgressManager.checkCanceled();
|
||||
checkCanceled.run();
|
||||
VirtualFile unknown = nameToFileMap.get(name);
|
||||
if (unknown.isDirectory()) {
|
||||
if (isInContent(unknown)) {
|
||||
|
||||
Reference in New Issue
Block a user