Search in sources :

Example 1 with ICvsFileSystem

use of org.netbeans.lib.cvsclient.file.ICvsFileSystem in project intellij-community by JetBrains.

the class CheckoutCommand method processExistingModules.

private void processExistingModules(ExpandedModules expandedModules, IClientEnvironment clientEnvironment) {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    for (final String moduleName : expandedModules.getModules()) {
        if (moduleName.equals(".")) {
            addFileObject(DirectoryObject.getRoot());
            break;
        }
        final File moduleFile = cvsFileSystem.getLocalFileSystem().getFile(moduleName);
        final AbstractFileObject abstractFileObject;
        final DirectoryObject directoryObject;
        if (moduleFile.isFile()) {
            abstractFileObject = cvsFileSystem.getLocalFileSystem().getFileObject(moduleFile);
            directoryObject = abstractFileObject.getParent();
        } else {
            directoryObject = cvsFileSystem.getLocalFileSystem().getDirectoryObject(moduleFile);
            abstractFileObject = directoryObject;
        }
        if (clientEnvironment.getAdminReader().hasCvsDirectory(directoryObject, cvsFileSystem)) {
            addFileObject(abstractFileObject);
        }
    }
}
Also used : ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) File(java.io.File) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 2 with ICvsFileSystem

use of org.netbeans.lib.cvsclient.file.ICvsFileSystem in project intellij-community by JetBrains.

the class DirectoryPruner method pruneEmptyDirectory.

// Utils ==================================================================
private boolean pruneEmptyDirectory(DirectoryObject directoryObject) throws IOException {
    final ILocalFileReader localFileReader = clientEnvironment.getLocalFileReader();
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    final IAdminReader adminReader = clientEnvironment.getAdminReader();
    directoriesToScan.remove(directoryObject);
    if (!localFileReader.exists(directoryObject, cvsFileSystem)) {
        return true;
    }
    final List fileNames = new ArrayList();
    final List directoryNames = new ArrayList();
    localFileReader.listFilesAndDirectories(directoryObject, fileNames, directoryNames, cvsFileSystem);
    if (fileNames.size() > 0) {
        return false;
    }
    if (hasFileEntry(directoryObject, cvsFileSystem, adminReader)) {
        return false;
    }
    for (Iterator it = directoryNames.iterator(); it.hasNext(); ) {
        final String directoryName = (String) it.next();
        if (!pruneEmptyDirectory(DirectoryObject.createInstance(directoryObject, directoryName))) {
            return false;
        }
    }
    if (adminReader.hasCvsDirectory(directoryObject, cvsFileSystem)) {
        try {
            adminWriter.removeEntryForFile(directoryObject, cvsFileSystem);
        } catch (FileNotFoundException ex) {
            // ignore
            return false;
        }
        adminWriter.pruneDirectory(directoryObject, cvsFileSystem);
        return true;
    }
    return false;
}
Also used : ILocalFileReader(org.netbeans.lib.cvsclient.file.ILocalFileReader) ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FileNotFoundException(java.io.FileNotFoundException) IAdminReader(org.netbeans.lib.cvsclient.admin.IAdminReader) IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ICvsFileSystem

use of org.netbeans.lib.cvsclient.file.ICvsFileSystem in project intellij-community by JetBrains.

the class ImportTree method getIgnoreFileFilter.

public IIgnoreFileFilter getIgnoreFileFilter() {
    final Collection<File> excludedFiles = new HashSet<>();
    for (final VirtualFile excludedFile : myExcludedFiles) {
        excludedFiles.add(CvsVfsUtil.getFileFor(excludedFile));
    }
    final Collection<File> includedFiles = new HashSet<>();
    for (VirtualFile includedFile : myIncludedFiles) {
        includedFiles.add(CvsVfsUtil.getFileFor(includedFile));
    }
    return new IIgnoreFileFilter() {

        private final Map<File, IgnoredFilesInfo> myParentToIgnoresMap = new HashMap<>();

        public boolean shouldBeIgnored(AbstractFileObject abstractFileObject, ICvsFileSystem cvsFileSystem) {
            final File file = cvsFileSystem.getLocalFileSystem().getFile(abstractFileObject);
            if (file.isDirectory() && file.getName().equals(CvsUtil.CVS))
                return true;
            if (FileTypeManager.getInstance().isFileIgnored(abstractFileObject.getName()))
                return true;
            final VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(file);
            if (myProject != null && !includedFiles.contains(file)) {
                if (vFile != null && isIgnoredByVcs(vFile)) {
                    return true;
                }
            }
            if (excludedFiles.contains(file))
                return true;
            final File parentFile = file.getParentFile();
            if (parentFile == null)
                return false;
            if (!myParentToIgnoresMap.containsKey(parentFile)) {
                myParentToIgnoresMap.put(parentFile, IgnoredFilesInfoImpl.createForFile(new File(parentFile, CvsUtil.CVS_IGNORE_FILE)));
            }
            return myParentToIgnoresMap.get(parentFile).shouldBeIgnored(vFile);
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) IIgnoreFileFilter(org.netbeans.lib.cvsclient.util.IIgnoreFileFilter) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HashMap(com.intellij.util.containers.HashMap) Map(java.util.Map) HashSet(com.intellij.util.containers.HashSet)

Example 4 with ICvsFileSystem

use of org.netbeans.lib.cvsclient.file.ICvsFileSystem in project intellij-community by JetBrains.

the class ExportCommand method processExistingModules.

private void processExistingModules(ExpandedModules expandedModules, IClientEnvironment clientEnvironment) {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    for (Iterator it = expandedModules.getModules().iterator(); it.hasNext(); ) {
        final String moduleName = (String) it.next();
        if (moduleName.equals(".")) {
            addFileObject(DirectoryObject.getRoot());
            break;
        }
        final File moduleFile = cvsFileSystem.getLocalFileSystem().getFile(moduleName);
        final AbstractFileObject abstractFileObject;
        final DirectoryObject directoryObject;
        if (moduleFile.isFile()) {
            abstractFileObject = cvsFileSystem.getLocalFileSystem().getFileObject(moduleFile);
            directoryObject = abstractFileObject.getParent();
        } else {
            directoryObject = cvsFileSystem.getLocalFileSystem().getDirectoryObject(moduleFile);
            abstractFileObject = directoryObject;
        }
        if (clientEnvironment.getAdminReader().hasCvsDirectory(directoryObject, cvsFileSystem)) {
            addFileObject(abstractFileObject);
        }
    }
}
Also used : ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) Iterator(java.util.Iterator) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) File(java.io.File) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Aggregations

ICvsFileSystem (org.netbeans.lib.cvsclient.file.ICvsFileSystem)4 File (java.io.File)3 AbstractFileObject (org.netbeans.lib.cvsclient.file.AbstractFileObject)3 Iterator (java.util.Iterator)2 DirectoryObject (org.netbeans.lib.cvsclient.file.DirectoryObject)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 IAdminReader (org.netbeans.lib.cvsclient.admin.IAdminReader)1 IAdminWriter (org.netbeans.lib.cvsclient.admin.IAdminWriter)1 ILocalFileReader (org.netbeans.lib.cvsclient.file.ILocalFileReader)1 IIgnoreFileFilter (org.netbeans.lib.cvsclient.util.IIgnoreFileFilter)1