From dd2541151d8db6079fb2e97202be227d7e359f3a Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 4 Apr 2011 15:37:41 +0400 Subject: [PATCH] IDEA-67402 VFS VCS listener: files, generated through VFS, menthioned in ignored pattern, are not ignored in listener --- .../intellij/openapi/vcs/ProjectLevelVcsManager.java | 1 + .../src/com/intellij/openapi/vcs/VcsVFSListener.java | 10 ++++++---- .../openapi/vcs/impl/ProjectLevelVcsManagerImpl.java | 9 +++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java index 55c990864dc6..b32647d344e6 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java @@ -256,4 +256,5 @@ public abstract class ProjectLevelVcsManager { protected abstract VcsEnvironmentsProxyCreator getProxyCreator(); public abstract VcsHistoryCache getVcsHistoryCache(); + public abstract boolean isFileInContent(final VirtualFile vf); } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java index 29de04c41f31..76c91c5e2629 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsVFSListener.java @@ -39,6 +39,7 @@ import java.util.*; */ public abstract class VcsVFSListener implements Disposable { private VcsDirtyScopeManager myDirtyScopeManager; + private final ProjectLevelVcsManager myVcsManager; protected static class MovedFileInfo { public final String myOldPath; @@ -75,9 +76,9 @@ public abstract class VcsVFSListener implements Disposable { final MyVirtualFileAdapter myVFSListener = new MyVirtualFileAdapter(); final MyCommandAdapter myCommandListener = new MyCommandAdapter(); - final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); - myAddOption = vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, vcs); - myRemoveOption = vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, vcs); + myVcsManager = ProjectLevelVcsManager.getInstance(project); + myAddOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, vcs); + myRemoveOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, vcs); VirtualFileManager.getInstance().addVirtualFileListener(myVFSListener, this); CommandProcessor.getInstance().addCommandListener(myCommandListener, this); @@ -87,7 +88,8 @@ public abstract class VcsVFSListener implements Disposable { } protected boolean isEventIgnored(final VirtualFileEvent event) { - return event.isFromRefresh() || ProjectLevelVcsManager.getInstance(myProject).getVcsFor(event.getFile()) != myVcs; + return event.isFromRefresh() || myVcsManager.getVcsFor(event.getFile()) != myVcs || + (! myVcsManager.isFileInContent(event.getFile())) || myChangeListManager.isIgnoredFile(event.getFile()); } protected void executeAdd() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 8468955a9c92..789d6ca1d591 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -108,8 +108,9 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme private final VcsHistoryCache myVcsHistoryCache; private MessageBusConnection myConnect; private VcsListener myVcsListener; + private final ExcludedFileIndex myExcludedIndex; - public ProjectLevelVcsManagerImpl(Project project, final FileStatusManager manager, MessageBus messageBus) { + public ProjectLevelVcsManagerImpl(Project project, final FileStatusManager manager, MessageBus messageBus, final ExcludedFileIndex excludedFileIndex) { myProject = project; myMessageBus = messageBus; mySerialization = new ProjectLevelVcsManagerSerialization(); @@ -135,6 +136,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme } }; myConnect.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, myVcsListener); + myExcludedIndex = excludedFileIndex; } public void initComponent() { @@ -719,9 +721,8 @@ public void addMessageToConsoleWindow(final String message, final TextAttributes } public boolean isFileInContent(final VirtualFile vf) { - final ExcludedFileIndex excludedIndex = ExcludedFileIndex.getInstance(myProject); - return vf != null && (excludedIndex.isInContent(vf) || isFileInBaseDir(vf) || vf.equals(myProject.getBaseDir()) || - hasExplicitMapping(vf) || isInDirectoryBasedRoot(vf)) && ! excludedIndex.isExcludedFile(vf); + return vf != null && (myExcludedIndex.isInContent(vf) || isFileInBaseDir(vf) || vf.equals(myProject.getBaseDir()) || + hasExplicitMapping(vf) || isInDirectoryBasedRoot(vf)) && ! myExcludedIndex.isExcludedFile(vf); } private boolean isInDirectoryBasedRoot(final VirtualFile file) {