Search in sources :

Example 1 with VirtualFileEntry

use of com.intellij.cvsSupport2.checkinProject.VirtualFileEntry in project intellij-community by JetBrains.

the class CvsChangeProvider method processEntriesIn.

private void processEntriesIn(@NotNull VirtualFile dir, VcsDirtyScope scope, ChangelistBuilder builder, boolean recursively, Collection<VirtualFile> cvsRoots, final ProgressIndicator progress) throws VcsException {
    final FilePath path = VcsContextFactory.SERVICE.getInstance().createFilePathOn(dir);
    if (!scope.belongsTo(path)) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Skipping out of scope path " + path);
        }
        return;
    }
    final DirectoryContent dirContent = getDirectoryContent(dir, progress);
    for (VirtualFile file : dirContent.getUnknownFiles()) {
        builder.processUnversionedFile(file);
    }
    for (VirtualFile file : dirContent.getIgnoredFiles()) {
        builder.processIgnoredFile(file);
    }
    for (Entry entry : dirContent.getDeletedDirectories()) {
        builder.processLocallyDeletedFile(VcsUtil.getFilePath(CvsVfsUtil.getFileFor(dir, entry.getFileName()), true));
    }
    for (Entry entry : dirContent.getDeletedFiles()) {
        builder.processLocallyDeletedFile(VcsUtil.getFilePath(CvsVfsUtil.getFileFor(dir, entry.getFileName()), false));
    }
    /*
    final Collection<VirtualFile> unknownDirs = dirContent.getUnknownDirectories();
    for (VirtualFile file : unknownDirs) {
      builder.processUnversionedFile(file);
    }
    */
    progress.checkCanceled();
    checkSwitchedDir(dir, builder, scope, cvsRoots);
    if (CvsUtil.fileIsUnderCvs(dir) && dir.getChildren().length == 1 && /* admin dir */
    dirContent.getDeletedFiles().isEmpty() && hasRemovedFiles(dirContent.getFiles())) {
        // directory is going to be deleted
        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, progress);
    }
    if (recursively) {
        for (VirtualFile file : CvsVfsUtil.getChildrenOf(dir)) {
            progress.checkCanceled();
            if (file.isDirectory()) {
                if (!myVcsManager.isIgnored(file)) {
                    processEntriesIn(file, scope, builder, true, cvsRoots, progress);
                } else {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Skipping ignored path " + file.getPath());
                    }
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) Entry(org.netbeans.lib.cvsclient.admin.Entry) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) DirectoryContent(com.intellij.cvsSupport2.checkinProject.DirectoryContent)

Example 2 with VirtualFileEntry

use of com.intellij.cvsSupport2.checkinProject.VirtualFileEntry in project intellij-community by JetBrains.

the class CvsChangeProvider method getDirectoryContent.

private static DirectoryContent getDirectoryContent(VirtualFile directory, final ProgressIndicator progress) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Retrieving directory content for " + directory);
    }
    final CvsInfo cvsInfo = CvsEntriesManager.getInstance().getCvsInfoFor(directory);
    final DirectoryContent result = new DirectoryContent(cvsInfo);
    final HashMap<String, VirtualFile> nameToFileMap = new HashMap<>();
    for (VirtualFile child : CvsVfsUtil.getChildrenOf(directory)) {
        nameToFileMap.put(child.getName(), child);
    }
    for (final Entry entry : cvsInfo.getEntries()) {
        progress.checkCanceled();
        final String fileName = entry.getFileName();
        if (entry.isDirectory()) {
            if (nameToFileMap.containsKey(fileName)) {
                final VirtualFile virtualFile = nameToFileMap.get(fileName);
                if (isInContent(virtualFile)) {
                    result.addDirectory(new VirtualFileEntry(virtualFile, entry));
                }
            } else if (!entry.isRemoved() && !FileTypeManager.getInstance().isFileIgnored(fileName)) {
                result.addDeletedDirectory(entry);
            }
        } else {
            if (nameToFileMap.containsKey(fileName) || entry.isRemoved()) {
                final VirtualFile virtualFile = nameToFileMap.get(fileName);
                if (isInContent(virtualFile)) {
                    result.addFile(new VirtualFileEntry(virtualFile, entry));
                }
            } else if (!entry.isAddedFile()) {
                result.addDeletedFile(entry);
            }
        }
        nameToFileMap.remove(fileName);
    }
    for (final String name : nameToFileMap.keySet()) {
        progress.checkCanceled();
        final VirtualFile unknown = nameToFileMap.get(name);
        if (unknown.isDirectory()) {
            if (isInContent(unknown)) {
                result.addUnknownDirectory(unknown);
            }
        } else {
            if (isInContent(unknown)) {
                final boolean isIgnored = result.getCvsInfo().getIgnoreFilter().shouldBeIgnored(unknown);
                if (isIgnored) {
                    result.addIgnoredFile(unknown);
                } else {
                    result.addUnknownFile(unknown);
                }
            }
        }
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) Entry(org.netbeans.lib.cvsclient.admin.Entry) HashMap(com.intellij.util.containers.HashMap) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) CvsInfo(com.intellij.cvsSupport2.application.CvsInfo) DirectoryContent(com.intellij.cvsSupport2.checkinProject.DirectoryContent)

Aggregations

DirectoryContent (com.intellij.cvsSupport2.checkinProject.DirectoryContent)2 VirtualFileEntry (com.intellij.cvsSupport2.checkinProject.VirtualFileEntry)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Entry (org.netbeans.lib.cvsclient.admin.Entry)2 CvsInfo (com.intellij.cvsSupport2.application.CvsInfo)1 HashMap (com.intellij.util.containers.HashMap)1