Search in sources :

Example 31 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class ClearCaseRemoveConsumer method consumeLine.

// ----------------------------------------------------------------------
// Stream Consumer Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (logger.isDebugEnabled()) {
        logger.debug(line);
    }
    int beginIndex = line.indexOf('"');
    if (beginIndex != -1) {
        String fileName = line.substring(beginIndex + 1, line.indexOf('"', beginIndex + 1));
        removedFiles.add(new ScmFile(fileName, ScmFileStatus.DELETED));
    }
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 32 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class AbstractCvsAddCommand method executeAddCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeAddCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
    CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
    Commandline cl = CvsCommandUtils.getBaseCommand("add", repository, fileSet);
    if (binary) {
        cl.createArg().setValue("-kb");
    }
    if (message != null && message.length() > 0) {
        cl.createArg().setValue("-m");
        cl.createArg().setValue("\"" + message + "\"");
    }
    List<ScmFile> addedFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
    for (File file : fileSet.getFileList()) {
        String path = file.getPath().replace('\\', '/');
        cl.createArg().setValue(path);
        addedFiles.add(new ScmFile(path, ScmFileStatus.ADDED));
    }
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + cl);
        getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
    }
    return executeCvsCommand(cl, addedFiles);
}
Also used : CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 33 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class CvsCheckInConsumer method consumeLine.

// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (logger.isDebugEnabled()) {
        logger.debug(line);
    }
    int end = line.indexOf(",v  <--  ");
    if (end == -1) {
        return;
    }
    String fileName = line.substring(0, end);
    if (!fileName.startsWith(remotePath)) {
        return;
    }
    fileName = fileName.substring(remotePath.length());
    checkedInFiles.add(new ScmFile(fileName, ScmFileStatus.CHECKED_IN));
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 34 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class CvsCheckOutConsumer method consumeLine.

/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (logger.isDebugEnabled()) {
        logger.debug(line);
    }
    if (line.length() < 3) {
        if (StringUtils.isNotEmpty(line)) {
            if (logger.isWarnEnabled()) {
                logger.warn("Unable to parse output from command: line length must be bigger than 3. (" + line + ").");
            }
        }
        return;
    }
    String status = line.substring(0, 2);
    String file = line.substring(2);
    file = file.substring(file.indexOf('/'));
    if (status.equals("U ")) {
        files.add(new ScmFile(file, ScmFileStatus.UPDATED));
    } else if (status.equals("P ")) {
        files.add(new ScmFile(file, ScmFileStatus.PATCHED));
    } else if (status.equals("C ")) {
        files.add(new ScmFile(file, ScmFileStatus.CONFLICT));
    } else {
        if (logger.isWarnEnabled()) {
            logger.warn("Unknown status: '" + status + "'.");
        }
    }
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 35 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class CvsDiffConsumer method consumeLine.

// ----------------------------------------------------------------------
// StreamConsumer Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
public void consumeLine(String line) {
    if (logger.isDebugEnabled()) {
        logger.debug(line);
    }
    if (line.startsWith(INDEX_TOKEN)) {
        // start a new file
        currentFile = line.substring(INDEX_TOKEN.length());
        changedFiles.add(new ScmFile(currentFile, ScmFileStatus.MODIFIED));
        currentDifference = new StringBuilder();
        differences.put(currentFile, currentDifference);
        patch.append(line).append("\n");
        return;
    }
    if (currentFile == null) {
        if (logger.isWarnEnabled()) {
            logger.warn("Unparseable line: '" + line + "'");
        }
        patch.append(line).append("\n");
        return;
    }
    if (line.startsWith(FILE_SEPARATOR_TOKEN)) {
        // skip
        patch.append(line).append("\n");
    } else if (line.startsWith(START_REVISION_TOKEN)) {
        // skip, though could parse to verify filename, start revision
        patch.append(line).append("\n");
    } else if (line.startsWith(END_REVISION_TOKEN)) {
        // skip, though could parse to verify filename, end revision
        patch.append(line).append("\n");
    } else if (line.startsWith(RCS_TOKEN)) {
    // skip, though could parse to verify filename
    } else if (line.startsWith(RETRIEVING_TOKEN)) {
    // skip, though could parse to verify version
    } else if (line.startsWith(DIFF_TOKEN)) {
    // skip, though could parse to verify command
    } else if (line.startsWith(ADDED_LINE_TOKEN) || line.startsWith(REMOVED_LINE_TOKEN) || line.startsWith(UNCHANGED_LINE_TOKEN) || line.startsWith(CHANGE_SEPARATOR_TOKEN) || line.equals(NO_NEWLINE_TOKEN)) {
        // add to buffer
        currentDifference.append(line).append("\n");
        patch.append(line).append("\n");
    } else {
        if (logger.isWarnEnabled()) {
            logger.warn("Unparseable line: '" + line + "'");
        }
        patch.append(line).append("\n");
        // skip to next file
        currentFile = null;
        currentDifference = null;
    }
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

ScmFile (org.apache.maven.scm.ScmFile)198 File (java.io.File)102 ArrayList (java.util.ArrayList)51 ScmException (org.apache.maven.scm.ScmException)34 BufferedReader (java.io.BufferedReader)21 DefaultLog (org.apache.maven.scm.log.DefaultLog)20 ScmFileStatus (org.apache.maven.scm.ScmFileStatus)19 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 InputStreamReader (java.io.InputStreamReader)16 ScmResult (org.apache.maven.scm.ScmResult)15 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)15 IOException (java.io.IOException)14 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)13 Matcher (java.util.regex.Matcher)11 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)11 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)10 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)10 Commandline (org.codehaus.plexus.util.cli.Commandline)10 SynergyScmProviderRepository (org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository)9 FileInputStream (java.io.FileInputStream)8