mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VCS: unversioned: changes are detected when VFS refresh events are send; ignored: test works :)
This commit is contained in:
@@ -276,24 +276,29 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
}
|
||||
|
||||
private VcsDirtyScopeManagerImpl getVcsManager() {
|
||||
try {
|
||||
return ((VcsDirtyScopeManagerImpl) VcsDirtyScopeManager.getInstance(myProject));
|
||||
}
|
||||
catch(ProcessCanceledException ex) {
|
||||
return null;
|
||||
}
|
||||
catch(Exception ex) {
|
||||
LOG.error(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateImmediately(final AtomicSectionsAware atomicSectionsAware) {
|
||||
FileHolderComposite composite;
|
||||
ChangeListWorker changeListWorker;
|
||||
final FileHolderComposite composite;
|
||||
final ChangeListWorker changeListWorker;
|
||||
|
||||
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
|
||||
if (! vcsManager.hasActiveVcss()) return;
|
||||
|
||||
final VcsDirtyScopeManagerImpl dirtyScopeManager;
|
||||
try {
|
||||
dirtyScopeManager = ((VcsDirtyScopeManagerImpl) VcsDirtyScopeManager.getInstanceChecked(myProject));
|
||||
}
|
||||
catch(ProcessCanceledException ex) {
|
||||
return;
|
||||
}
|
||||
catch(Exception ex) {
|
||||
LOG.error(ex);
|
||||
return;
|
||||
}
|
||||
final VcsDirtyScopeManagerImpl dirtyScopeManager = getVcsManager();
|
||||
if (dirtyScopeManager == null) return;
|
||||
|
||||
final VcsInvalidated invalidated = dirtyScopeManager.retrieveScopes();
|
||||
if (invalidated == null || invalidated.isEmpty()) {
|
||||
// a hack here; but otherwise everything here should be refactored ;)
|
||||
@@ -305,6 +310,8 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
final boolean wasEverythingDirty = invalidated.isEverythingDirty();
|
||||
final List<VcsDirtyScope> scopes = invalidated.getScopes();
|
||||
|
||||
|
||||
|
||||
try {
|
||||
checkIfDisposed();
|
||||
|
||||
|
||||
+21
-15
@@ -22,7 +22,8 @@ import com.intellij.openapi.project.ProjectLocator;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FilePathImpl;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.*;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -71,13 +72,15 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL
|
||||
// collect files and directories - sources of events
|
||||
for (VFileEvent event : events) {
|
||||
final VirtualFile file = getFileForEvent(event);
|
||||
if (file == null) { continue; }
|
||||
if (file == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event instanceof VFileDeleteEvent) {
|
||||
if (!file.isInLocalFileSystem()) { continue; }
|
||||
dirtyFilesAndDirs.add(file);
|
||||
dirtyFilesAndDirs.add(file, true);
|
||||
} else if (event instanceof VFileMoveEvent || event instanceof VFilePropertyChangeEvent) {
|
||||
dirtyFilesAndDirs.addToFiles(file);
|
||||
dirtyFilesAndDirs.addToFiles(file, false); // todo ?
|
||||
}
|
||||
}
|
||||
// and notify VCSDirtyScopeManager
|
||||
@@ -90,20 +93,22 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL
|
||||
// collect files and directories - sources of events
|
||||
for (VFileEvent event : events) {
|
||||
final VirtualFile file = getFileForEvent(event);
|
||||
if (file == null) { continue; }
|
||||
if (file == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event instanceof VFileContentChangeEvent || event instanceof VFileCopyEvent || event instanceof VFileCreateEvent) {
|
||||
dirtyFilesAndDirs.addToFiles(file);
|
||||
dirtyFilesAndDirs.add(file, false);
|
||||
} else if (event instanceof VFilePropertyChangeEvent) {
|
||||
final VFilePropertyChangeEvent pce = (VFilePropertyChangeEvent) event;
|
||||
|
||||
if (pce.getPropertyName().equals(VirtualFile.PROP_NAME)) {
|
||||
// if a file was renamed, then the file is dirty and its parent directory is dirty too;
|
||||
// if a directory was renamed, all its children are recursively dirty, the parent dir is also dirty but not recursively.
|
||||
dirtyFilesAndDirs.add(file); // the file is dirty recursively
|
||||
dirtyFilesAndDirs.addToFiles(file.getParent()); // directory is dirty alone. if parent is null - is checked in the method
|
||||
dirtyFilesAndDirs.add(file, false); // the file is dirty recursively
|
||||
dirtyFilesAndDirs.addToFiles(file.getParent(), false); // directory is dirty alone. if parent is null - is checked in the method
|
||||
} else {
|
||||
dirtyFilesAndDirs.addToFiles(file);
|
||||
dirtyFilesAndDirs.addToFiles(file, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,11 +138,12 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL
|
||||
* @param file file which path is to be added.
|
||||
* @param addToFiles If true, then add to dirty files even if it is a directory. Otherwise add to the proper set.
|
||||
*/
|
||||
private void add(VirtualFile file, boolean addToFiles) {
|
||||
public void add(VirtualFile file, boolean addToFiles, final boolean forDelete) {
|
||||
if (file == null) { return; }
|
||||
final boolean isDirectory = file.isDirectory();
|
||||
// need to create FilePath explicitly without referring to VirtualFile because the path of VirtualFile may change
|
||||
final FilePathImpl path = new FilePathImpl(new File(file.getPath()), isDirectory);
|
||||
final FilePathImpl path = forDelete ? new FilePathImpl(new File(file.getPath()), isDirectory) :
|
||||
new FilePathImpl(file);
|
||||
|
||||
final Collection<VcsDirtyScopeManager> managers = getManagers(file);
|
||||
for (VcsDirtyScopeManager manager : managers) {
|
||||
@@ -158,16 +164,16 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL
|
||||
/**
|
||||
* Adds files to the collection of files and directories - to the collection of directories (which are handled recursively).
|
||||
*/
|
||||
void add(VirtualFile file) {
|
||||
add(file, false);
|
||||
void add(VirtualFile file, final boolean forDelete) {
|
||||
add(file, false, forDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the collection of files. A file (even if it is a directory) is marked dirty alone (not recursively).
|
||||
* Use this method, when you want directory not to be marked dirty recursively.
|
||||
*/
|
||||
void addToFiles(VirtualFile file) {
|
||||
add(file, true);
|
||||
void addToFiles(VirtualFile file, final boolean forDelete) {
|
||||
add(file, true, forDelete);
|
||||
}
|
||||
|
||||
void markDirty() {
|
||||
|
||||
@@ -4,16 +4,22 @@ import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.IgnoredBeanFactory;
|
||||
import com.intellij.openapi.vcs.changes.IgnoredFileBean;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.AbstractVcsTestCase;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.testFramework.fixtures.TempDirTestFixture;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -46,7 +52,7 @@ public class IgnoredFilesTest extends AbstractVcsTestCase {
|
||||
myVcs = SvnVcs.getInstance(myProject);
|
||||
myVcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(myProject);
|
||||
myVcsManager.registerVcs(myVcs);
|
||||
myVcsManager.setDirectoryMapping("", myVcs.getName());
|
||||
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
|
||||
|
||||
((ProjectComponent) myChangeListManager).projectOpened();
|
||||
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||
@@ -72,7 +78,7 @@ public class IgnoredFilesTest extends AbstractVcsTestCase {
|
||||
}
|
||||
|
||||
// they all blink now
|
||||
/*
|
||||
|
||||
@Test
|
||||
public void testFileIsIgnored() throws Exception {
|
||||
final String filePath1 = myClientRoot.getPath() + "/a";
|
||||
@@ -97,8 +103,8 @@ public class IgnoredFilesTest extends AbstractVcsTestCase {
|
||||
|
||||
@Test
|
||||
public void testDirIsIgnored() throws Exception {
|
||||
final String dirPath1 = myClientRoot.getPath() + "/a";
|
||||
final File dir = new File(dirPath1);
|
||||
//final String dirPath1 = myClientRoot.getPath() + "/a";
|
||||
final File dir = new File(myClientRoot, "a");
|
||||
dir.mkdir();
|
||||
final File innerDir = new File(dir, "innerDir");
|
||||
innerDir.mkdir();
|
||||
@@ -111,7 +117,7 @@ public class IgnoredFilesTest extends AbstractVcsTestCase {
|
||||
final VirtualFile vf1 = myLocalFileSystem.refreshAndFindFileByIoFile(file1);
|
||||
final VirtualFile vf2 = myLocalFileSystem.refreshAndFindFileByIoFile(file2);
|
||||
|
||||
final IgnoredFileBean ignoredFileBean = IgnoredBeanFactory.ignoreUnderDirectory(dirPath1, myProject);
|
||||
final IgnoredFileBean ignoredFileBean = IgnoredBeanFactory.ignoreUnderDirectory(FileUtil.toSystemIndependentName(dir.getPath()), myProject);
|
||||
myChangeListManager.addFilesToIgnore(ignoredFileBean);
|
||||
|
||||
dirty();
|
||||
@@ -124,7 +130,7 @@ public class IgnoredFilesTest extends AbstractVcsTestCase {
|
||||
@Test
|
||||
public void testPatternIsIgnored() throws Exception {
|
||||
final String dirPath1 = myClientRoot.getPath() + "/a";
|
||||
final File dir = new File(dirPath1);
|
||||
final File dir = new File(myClientRoot, "a");
|
||||
dir.mkdir();
|
||||
final File innerDir = new File(dir, "innerDir");
|
||||
innerDir.mkdir();
|
||||
@@ -155,5 +161,5 @@ public class IgnoredFilesTest extends AbstractVcsTestCase {
|
||||
Assert.assertNotNull(vf);
|
||||
Assert.assertTrue(myChangeListManager.isIgnoredFile(vf));
|
||||
Assert.assertEquals(FileStatus.IGNORED, myChangeListManager.getStatus(vf));
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user