Search in sources :

Example 1 with DirectoryContent

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent 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 DirectoryContent

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent in project intellij-community by JetBrains.

the class RootDataProvider method getDirectoryContent.

@Override
public DirectoryContent getDirectoryContent() {
    final DirectoryContent result = new DirectoryContent();
    result.copyDataFrom(myDirectoryListOperation.getDirectoryContent());
    result.copyDataFrom(myModuleListOperation.getDirectoryContent());
    return result;
}
Also used : DirectoryContent(com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent)

Example 3 with DirectoryContent

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent in project intellij-community by JetBrains.

the class GetModuleContentOperation method createGetModuleContentOperation.

private LocalPathIndifferentOperation createGetModuleContentOperation(RepositoryPathProvider adminWriter, CvsEnvironment environment, final String moduleName) {
    final LocalPathIndifferentOperation operation = new LocalPathIndifferentOperation(new AdminReaderOnStoredRepositoryPath(adminWriter), environment) {

        private boolean myIsInModule = false;

        @Override
        protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
            final CheckoutCommand result = new CheckoutCommand(null);
            result.addModule(moduleName);
            result.setRecursive(true);
            return result;
        }

        @Override
        protected ILocalFileReader createLocalFileReader() {
            return ConstantLocalFileReader.FOR_EXISTING_FILE;
        }

        @Override
        protected String getOperationName() {
            return "checkout";
        }

        @Override
        protected ILocalFileWriter createLocalFileWriter(String cvsRoot, UpdatedFilesManager mergedFilesCollector, CvsExecutionEnvironment cvsExecutionEnvironment) {
            return DeafLocalFileWriter.INSTANCE;
        }

        @Override
        public void messageSent(String message, final byte[] byteMessage, boolean error, boolean tagged) {
            super.messageSent(message, byteMessage, error, tagged);
            myStreamingDirectoryContentListener.setModulePath(myAdminWriterStoringRepositoryPath.getModulePath());
            final Matcher matcher = UPDATING_PATTERN.matcher(message);
            if (matcher.matches()) {
                if (myModuleLocation != null && myModuleLocation.equals(matcher.group(1))) {
                    myIsInModule = true;
                } else {
                    myStreamingDirectoryContentListener.messageSent(message);
                    myIsInModule = false;
                }
            } else if (DirectoryContentListener.moduleMessage_ver1(message)) {
                myIsInModule = true;
            }
            if (myIsInModule) {
                myStreamingDirectoryContentListener.messageSent(message);
            }
            final DirectoryContent streamingDirectoryContent = myStreamingDirectoryContentListener.getDirectoryContent();
            if (myStreamingListener != null) {
                final long timePassed = System.currentTimeMillis() - timeStamp;
                if (streamingDirectoryContent.getTotalSize() > 0 && timePassed > 25L) {
                    myStreamingListener.consume(streamingDirectoryContent);
                    final DirectoryContentListener newListener = new DirectoryContentListener();
                    newListener.setModuleName(myStreamingDirectoryContentListener.getModuleName());
                    myStreamingDirectoryContentListener = newListener;
                    timeStamp = System.currentTimeMillis();
                }
            } else {
                myDirectoryContentListener.getDirectoryContent().copyDataFrom(streamingDirectoryContent);
            }
        }

        @Override
        public void modifyOptions(GlobalOptions options) {
            super.modifyOptions(options);
            options.setDoNoChanges(true);
        }
    };
    operation.addFinishAction(() -> myStreamingListener.consume(myStreamingDirectoryContentListener.getDirectoryContent()));
    return operation;
}
Also used : GlobalOptions(org.netbeans.lib.cvsclient.command.GlobalOptions) AdminReaderOnStoredRepositoryPath(com.intellij.cvsSupport2.cvsoperations.javacvsSpecificImpls.AdminReaderOnStoredRepositoryPath) CheckoutCommand(org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand) Matcher(java.util.regex.Matcher) CvsRootProvider(com.intellij.cvsSupport2.connections.CvsRootProvider)

Example 4 with DirectoryContent

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent 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)

Example 5 with DirectoryContent

use of com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent in project intellij-community by JetBrains.

the class AbstractVcsDataProvider method fillContentFor.

@Override
public void fillContentFor(final GetContentCallback callback, Consumer<VcsException> errorCallback) {
    myErrorCallback = errorCallback;
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        executeCommand(createDirectoryContentProvider(callback.getElementPath()), callback);
    } else {
        final DirectoryContentProvider provider = createDirectoryContentProvider(callback.getElementPath());
        provider.setStreamingListener(directoryContent -> callback.appendDirectoryContent(directoryContent));
        executeCommand(provider, callback);
    }
}
Also used : DirectoryContentProvider(com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContentProvider)

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 CvsRootProvider (com.intellij.cvsSupport2.connections.CvsRootProvider)1 DirectoryContent (com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContent)1 DirectoryContentProvider (com.intellij.cvsSupport2.cvsoperations.cvsContent.DirectoryContentProvider)1 AdminReaderOnStoredRepositoryPath (com.intellij.cvsSupport2.cvsoperations.javacvsSpecificImpls.AdminReaderOnStoredRepositoryPath)1 HashMap (com.intellij.util.containers.HashMap)1 Matcher (java.util.regex.Matcher)1 GlobalOptions (org.netbeans.lib.cvsclient.command.GlobalOptions)1 CheckoutCommand (org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand)1