Search in sources :

Example 46 with ScmFile

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

the class TfsTagCommand method executeTagCommand.

protected ScmResult executeTagCommand(ScmProviderRepository r, ScmFileSet f, String tag, ScmTagParameters scmTagParameters) throws ScmException {
    TfsCommand command = createCommand(r, f, tag, scmTagParameters);
    StringStreamConsumer out = new StringStreamConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    int status = command.execute(out, err);
    if (status != 0 || err.hasBeenFed()) {
        return new TagScmResult(command.getCommandString(), "Error code for TFS label command - " + status, err.getOutput(), false);
    }
    List<ScmFile> files = new ArrayList<ScmFile>(f.getFileList().size());
    for (File file : f.getFileList()) {
        files.add(new ScmFile(file.getPath(), ScmFileStatus.TAGGED));
    }
    return new TagScmResult(command.getCommandString(), files);
}
Also used : ArrayList(java.util.ArrayList) StringStreamConsumer(org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 47 with ScmFile

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

the class VssTagConsumer method processGetFile.

/**
 * Process the current input line in the Get File state.
 *
 * @param line a line of text from the VSS log output
 */
private void processGetFile(String line) {
    String[] fileLine = line.split(" ");
    updatedFiles.add(new ScmFile(currentPath + "/" + fileLine[1], ScmFileStatus.UPDATED));
    if (getLogger().isInfoEnabled()) {
        getLogger().info(fileLine[0] + ": " + currentPath + "/" + fileLine[1]);
    }
}
Also used : ScmFile(org.apache.maven.scm.ScmFile)

Example 48 with ScmFile

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

the class TfsBranchCommand method executeBranchCommand.

protected ScmResult executeBranchCommand(ScmProviderRepository r, ScmFileSet f, String branch, String message) throws ScmException {
    TfsCommand command = createCommand(r, f, branch);
    StringStreamConsumer out = new StringStreamConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    int status = command.execute(out, err);
    getLogger().info("status of branch command is= " + status + "; err= " + err.getOutput());
    if (status != 0 || err.hasBeenFed()) {
        return new BranchScmResult(command.getCommandString(), "Error code for TFS branch command - " + status, err.getOutput(), false);
    }
    return new BranchScmResult(command.getCommandString(), new ArrayList<ScmFile>(0));
}
Also used : StringStreamConsumer(org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Example 49 with ScmFile

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

the class TfsCommand method execute.

public int execute(StreamConsumer out, ErrorStreamConsumer err) throws ScmException {
    info("Command line - " + getCommandString());
    int status;
    try {
        status = CommandLineUtils.executeCommandLine(command, out, err);
    } catch (CommandLineException e) {
        throw new ScmException("Error while executing TFS command line - " + getCommandString(), e);
    }
    info("err - " + err.getOutput());
    if (out instanceof StringStreamConsumer) {
        StringStreamConsumer sc = (StringStreamConsumer) out;
        debug(sc.getOutput());
    }
    if (out instanceof FileListConsumer) {
        FileListConsumer f = (FileListConsumer) out;
        for (Iterator<ScmFile> i = f.getFiles().iterator(); i.hasNext(); ) {
            ScmFile file = i.next();
            debug(file.getPath());
        }
    }
    return status;
}
Also used : FileListConsumer(org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer) ScmException(org.apache.maven.scm.ScmException) StringStreamConsumer(org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) ScmFile(org.apache.maven.scm.ScmFile)

Example 50 with ScmFile

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

the class CvsTagConsumer 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);
    if (status.equals("T ")) {
        files.add(new ScmFile(file, ScmFileStatus.TAGGED));
    } else {
        if (logger.isWarnEnabled()) {
            logger.warn("Unknown status: '" + status + "'.");
        }
    }
}
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