mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: do not mark files dirty in the VcsVfsListener
Marking affected files dirty at the end of the CommandListener, makes no sense, since all custom implementations of VcsVfsListener perform addition/deletion/move in the background. Marking affected files dirty should be done after these background procedures complete. The API doesn't provide a common way to do it, but all implementations should do it on their own.
This commit is contained in:
committed by
Dmitry Zhuravlev
parent
1e9909e575
commit
ff1a94ba41
@@ -11,7 +11,6 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -29,7 +28,6 @@ import java.util.*;
|
||||
public abstract class VcsVFSListener implements Disposable {
|
||||
protected static final Logger LOG = Logger.getInstance(VcsVFSListener.class);
|
||||
|
||||
private final VcsDirtyScopeManager myDirtyScopeManager;
|
||||
private final ProjectLevelVcsManager myVcsManager;
|
||||
private final VcsFileListenerContextHelper myVcsFileListenerContextHelper;
|
||||
|
||||
@@ -64,7 +62,6 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
protected final List<FilePath> myDeletedFiles = new ArrayList<>();
|
||||
protected final List<FilePath> myDeletedWithoutConfirmFiles = new ArrayList<>();
|
||||
protected final List<MovedFileInfo> myMovedFiles = new ArrayList<>();
|
||||
private final LinkedHashSet<VirtualFile> myDirtyFiles = ContainerUtil.newLinkedHashSet();
|
||||
|
||||
protected enum VcsDeleteType {SILENT, CONFIRM, IGNORE}
|
||||
|
||||
@@ -72,7 +69,6 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
myProject = project;
|
||||
myVcs = vcs;
|
||||
myChangeListManager = ChangeListManager.getInstance(project);
|
||||
myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
|
||||
myVcsManager = ProjectLevelVcsManager.getInstance(project);
|
||||
myAddOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, vcs);
|
||||
@@ -87,13 +83,9 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
protected boolean isEventIgnored(@NotNull VirtualFileEvent event, boolean putInDirty) {
|
||||
protected boolean isEventIgnored(@NotNull VirtualFileEvent event) {
|
||||
if (event.isFromRefresh()) return true;
|
||||
boolean vcsIgnored = !isUnderMyVcs(event.getFile());
|
||||
if (vcsIgnored) {
|
||||
myDirtyFiles.add(event.getFile());
|
||||
}
|
||||
return vcsIgnored;
|
||||
return !isUnderMyVcs(event.getFile());
|
||||
}
|
||||
|
||||
private boolean isUnderMyVcs(@NotNull VirtualFile file) {
|
||||
@@ -217,7 +209,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
}
|
||||
|
||||
protected void fileAdded(@NotNull VirtualFileEvent event, @NotNull VirtualFile file) {
|
||||
if (!isEventIgnored(event, true) && !myChangeListManager.isIgnoredFile(file) &&
|
||||
if (!isEventIgnored(event) && !myChangeListManager.isIgnoredFile(file) &&
|
||||
(isDirectoryVersioningSupported() || !file.isDirectory())) {
|
||||
LOG.debug("Adding [", file, "] to added files");
|
||||
myAddedFiles.add(event.getFile());
|
||||
@@ -245,12 +237,6 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
protected void processMovedFile(@NotNull VirtualFile file, @NotNull String newParentPath, @NotNull String newName) {
|
||||
final FileStatus status = ChangeListManager.getInstance(myProject).getStatus(file);
|
||||
LOG.debug("Checking moved file ", file, "; status=", status);
|
||||
if (status == FileStatus.IGNORED) {
|
||||
if (file.getParent() != null) {
|
||||
myDirtyFiles.add(file.getParent());
|
||||
myDirtyFiles.add(file); // will be at new path
|
||||
}
|
||||
}
|
||||
|
||||
String newPath = newParentPath + "/" + newName;
|
||||
if (!(filterOutUnknownFiles() && status == FileStatus.UNKNOWN) && status != FileStatus.IGNORED) {
|
||||
@@ -322,7 +308,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
|
||||
@Override
|
||||
public void fileCopied(@NotNull final VirtualFileCopyEvent event) {
|
||||
if (isEventIgnored(event, true) || myChangeListManager.isIgnoredFile(event.getFile())) return;
|
||||
if (isEventIgnored(event) || myChangeListManager.isIgnoredFile(event.getFile())) return;
|
||||
final AbstractVcs oldVcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getOriginalFile());
|
||||
if (oldVcs == myVcs) {
|
||||
final VirtualFile parent = event.getFile().getParent();
|
||||
@@ -339,7 +325,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
@Override
|
||||
public void beforeFileDeletion(@NotNull final VirtualFileEvent event) {
|
||||
final VirtualFile file = event.getFile();
|
||||
if (isEventIgnored(event, true)) {
|
||||
if (isEventIgnored(event)) {
|
||||
return;
|
||||
}
|
||||
if (!myChangeListManager.isIgnoredFile(file)) {
|
||||
@@ -360,7 +346,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
|
||||
@Override
|
||||
public void beforeFileMovement(@NotNull final VirtualFileMoveEvent event) {
|
||||
if (isEventIgnored(event, true)) return;
|
||||
if (isEventIgnored(event)) return;
|
||||
final VirtualFile file = event.getFile();
|
||||
final AbstractVcs newVcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getNewParent());
|
||||
LOG.debug("beforeFileMovement ", event, " into ", newVcs);
|
||||
@@ -374,7 +360,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
|
||||
@Override
|
||||
public void fileMoved(@NotNull final VirtualFileMoveEvent event) {
|
||||
if (isEventIgnored(event, true)) return;
|
||||
if (isEventIgnored(event)) return;
|
||||
final AbstractVcs oldVcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getOldParent());
|
||||
if (oldVcs != myVcs) {
|
||||
myAddedFiles.add(event.getFile());
|
||||
@@ -383,7 +369,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
|
||||
@Override
|
||||
public void beforePropertyChange(@NotNull final VirtualFilePropertyEvent event) {
|
||||
if (!isEventIgnored(event, false) && event.getPropertyName().equalsIgnoreCase(VirtualFile.PROP_NAME)) {
|
||||
if (!isEventIgnored(event) && event.getPropertyName().equalsIgnoreCase(VirtualFile.PROP_NAME)) {
|
||||
LOG.debug("before file rename ", event);
|
||||
String oldName = (String)event.getOldValue();
|
||||
String newName = (String)event.getNewValue();
|
||||
@@ -461,8 +447,7 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
if (myProject != event.getProject()) return;
|
||||
myCommandLevel--;
|
||||
if (myCommandLevel == 0) {
|
||||
if (!myAddedFiles.isEmpty() || !myDeletedFiles.isEmpty() || !myDeletedWithoutConfirmFiles.isEmpty() || !myMovedFiles.isEmpty() ||
|
||||
! myDirtyFiles.isEmpty()) {
|
||||
if (!myAddedFiles.isEmpty() || !myDeletedFiles.isEmpty() || !myDeletedWithoutConfirmFiles.isEmpty() || !myMovedFiles.isEmpty()) {
|
||||
doNotDeleteAddedCopiedOrMovedFiles();
|
||||
checkMovedAddedSourceBack();
|
||||
if (!myAddedFiles.isEmpty()) {
|
||||
@@ -478,21 +463,6 @@ public abstract class VcsVFSListener implements Disposable {
|
||||
executeMoveRename();
|
||||
myMovedFiles.clear();
|
||||
}
|
||||
if (! myDirtyFiles.isEmpty()) {
|
||||
final List<VirtualFile> files = new ArrayList<>();
|
||||
final List<VirtualFile> dirs = new ArrayList<>();
|
||||
for (VirtualFile dirtyFile : myDirtyFiles) {
|
||||
if (dirtyFile != null) {
|
||||
if (dirtyFile.isDirectory()) {
|
||||
dirs.add(dirtyFile);
|
||||
} else {
|
||||
files.add(dirtyFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
myDirtyScopeManager.filesDirty(files, dirs);
|
||||
myDirtyFiles.clear();
|
||||
}
|
||||
if (! myExceptions.isEmpty()) {
|
||||
AbstractVcsHelper.getInstance(myProject).showErrors(myExceptions, myVcs.getDisplayName() + " operations errors");
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public class GitVFSListener extends VcsVFSListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEventIgnored(@NotNull VirtualFileEvent event, boolean putInDirty) {
|
||||
return super.isEventIgnored(event, putInDirty) || myEventsSuppressLevel.get() != 0;
|
||||
protected boolean isEventIgnored(@NotNull VirtualFileEvent event) {
|
||||
return super.isEventIgnored(event) || myEventsSuppressLevel.get() != 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user