Search in sources :

Example 1 with FileObject

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

the class ImportCommand method addFileRequests.

/**
	 * Adds recursively all request for files and directories in the specified
	 * directory to the specified requestList.
	 */
private void addFileRequests(File directory, Requests requests, IRequestProcessor requestProcessor, IClientEnvironment clientEnvironment) throws IOException {
    final DirectoryObject directoryObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(directory);
    final String relativePath = directoryObject.toUnixPath();
    String repository = getRepositoryRoot(clientEnvironment);
    if (!relativePath.equals(".")) {
        repository += '/' + relativePath;
    }
    requests.addRequest(new DirectoryRequest(relativePath, repository));
    final File[] files = directory.listFiles();
    if (files == null) {
        return;
    }
    final List<File> subdirectories = new ArrayList();
    for (final File file : files) {
        if (file.isDirectory()) {
            final DirectoryObject subDirObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(file);
            if (clientEnvironment.getIgnoreFileFilter().shouldBeIgnored(subDirObject, clientEnvironment.getCvsFileSystem())) {
                continue;
            }
            subdirectories.add(file);
        } else {
            final FileObject fileObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getFileObject(file);
            if (clientEnvironment.getIgnoreFileFilter().shouldBeIgnored(fileObject, clientEnvironment.getCvsFileSystem())) {
                continue;
            }
            final KeywordSubstitution keywordSubstMode = getKeywordSubstMode(file.getName());
            final boolean writable = clientEnvironment.getLocalFileReader().isWritable(fileObject, clientEnvironment.getCvsFileSystem());
            if (keywordSubstMode != null) {
                requests.addKoptRequest(keywordSubstMode);
            }
            requests.addModifiedRequest(fileObject, keywordSubstMode == KeywordSubstitution.BINARY, writable);
        }
    }
    for (final File subdirectory : subdirectories) {
        addFileRequests(subdirectory, requests, requestProcessor, clientEnvironment);
    }
}
Also used : FileObject(org.netbeans.lib.cvsclient.file.FileObject) DirectoryRequest(org.netbeans.lib.cvsclient.request.DirectoryRequest) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject) File(java.io.File)

Example 2 with FileObject

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

the class StatusMessageParser method createFile.

// Utils ==================================================================
private File createFile(String fileName) {
    File file = null;
    if (relativeDirectory != null) {
        if (relativeDirectory.trim().equals(".")) {
            file = cvsFileSystem.getLocalFileSystem().getFile(fileName);
        } else {
            file = cvsFileSystem.getLocalFileSystem().getFile(relativeDirectory + '/' + fileName);
        }
    } else {
        for (Iterator it = fileObjects.iterator(); it.hasNext(); ) {
            final AbstractFileObject abstractFileObject = (AbstractFileObject) it.next();
            if (abstractFileObject instanceof FileObject) {
                final FileObject fileObject = (FileObject) abstractFileObject;
                if (!fileObject.getName().equals(fileName)) {
                    continue;
                }
                it.remove();
                return cvsFileSystem.getLocalFileSystem().getFile(fileObject);
            }
            it.remove();
        }
    }
    BugLog.getInstance().assertTrue(file != null, "Wrong algorithm for detecting file name (" + fileName + ")");
    return file;
}
Also used : Iterator(java.util.Iterator) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) FileObject(org.netbeans.lib.cvsclient.file.FileObject) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) File(java.io.File)

Example 3 with FileObject

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

the class FileSystemScanner method scan.

// Actions ================================================================
public void scan(List<AbstractFileObject> abstractFileObjects, CvsFiles cvsFiles) throws IOException {
    cvsFiles.clear();
    if (abstractFileObjects.size() == 0) {
        // if no arguments have been specified, then specify the
        // local directory - the "top level" for this command
        scanDirectories(DirectoryObject.getRoot(), cvsFiles);
    } else {
        for (final AbstractFileObject fileOrDirectory : abstractFileObjects) {
            if (fileOrDirectory instanceof DirectoryObject) {
                final DirectoryObject directoryObject = (DirectoryObject) fileOrDirectory;
                scanDirectories(directoryObject, cvsFiles);
            } else if (fileOrDirectory instanceof FileObject) {
                final FileObject fileObject = (FileObject) fileOrDirectory;
                addRequestsForFile(fileObject, cvsFiles);
            }
        }
    }
}
Also used : AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) FileObject(org.netbeans.lib.cvsclient.file.FileObject) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 4 with FileObject

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

the class UpdateMessageParser method parseLine.

@SuppressWarnings({ "HardCodedStringLiteral" })
public void parseLine(String line, boolean isErrorMessage) {
    if (line.startsWith("RCS file:")) {
        return;
    }
    if (line.startsWith("retrieving revision ")) {
        return;
    }
    if (line.indexOf(" already contains the differences between ") > 0) {
        return;
    }
    if (line.startsWith("rcsmerge: warning: conflicts during merge")) {
        return;
    }
    if (line.indexOf(EXAM_DIR) >= 0) {
        return;
    }
    if (line.indexOf(": conflicts found in ") > 0) {
        return;
    }
    int index = line.indexOf(UNKNOWN);
    if (index >= 0) {
        final String fileName = (line.substring(index + UNKNOWN.length())).trim();
        processUnknown(fileName);
        return;
    }
    index = line.indexOf(TO_ADD);
    if (index >= 0) {
        final String fileName = (line.substring(index + TO_ADD.length())).trim();
        processUnknown(fileName);
        return;
    }
    if (line.startsWith(MERGING)) {
        //			fileInfoContainer.setType(DefaultFileInfoContainer.MERGED_FILE);
        return;
    }
    index = line.indexOf(LOCALLY_MODIFIED_FILE_HAS_BEEN_REMOVED);
    if (index >= 0) {
        String warningPrefix = "cvs server: file ";
        if (!line.startsWith(warningPrefix))
            return;
        final String fileName = line.substring(warningPrefix.length(), index).trim();
        final FileObject fileObject = cvsFileSystem.unixFileNameToFileObject(fileName);
        ensureExistingFileInfoContainer(fileObject);
        // HACK - will create conflict status in order to be able to have consistent info format
        fileInfo.setType("C");
        return;
    }
    index = line.indexOf(WARNING);
    if (index >= 0) {
        final int pertinentIndex = line.indexOf(PERTINENT);
        if (pertinentIndex > 0) {
            final String fileName = line.substring(index + WARNING.length(), pertinentIndex).trim();
            final FileObject fileObject = cvsFileSystem.unixFileNameToFileObject(fileName);
            processNotPertinent(fileObject);
        }
        return;
    }
    Matcher m = NOT_IN_REPOSITORY_PATTERN.matcher(line);
    if (m.matches()) {
        final String fileName = m.group(1).trim();
        final FileObject fileObject = cvsFileSystem.unixFileNameToFileObject(fileName);
        processNotPertinent(fileObject);
        return;
    }
    // otherwise
    if (line.length() > 2) {
        if (line.charAt(1) == ' ') {
            final String firstChar = line.substring(0, 1);
            if (STATES.indexOf(firstChar) >= 0) {
                processFile(line.substring(2), firstChar);
            }
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) FileObject(org.netbeans.lib.cvsclient.file.FileObject)

Example 5 with FileObject

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

the class UpdateMessageParser method processFile.

private void processFile(String fileName, String type) {
    final FileObject fileObject = cvsFileSystem.unixFileNameToFileObject(fileName);
    ensureExistingFileInfoContainer(fileObject);
    fileInfo.setType(type);
}
Also used : FileObject(org.netbeans.lib.cvsclient.file.FileObject)

Aggregations

FileObject (org.netbeans.lib.cvsclient.file.FileObject)8 AbstractFileObject (org.netbeans.lib.cvsclient.file.AbstractFileObject)3 DirectoryObject (org.netbeans.lib.cvsclient.file.DirectoryObject)3 File (java.io.File)2 Iterator (java.util.Iterator)1 Matcher (java.util.regex.Matcher)1 Entry (org.netbeans.lib.cvsclient.admin.Entry)1 AbstractFileStateRequest (org.netbeans.lib.cvsclient.request.AbstractFileStateRequest)1 DirectoryRequest (org.netbeans.lib.cvsclient.request.DirectoryRequest)1