Search in sources :

Example 1 with CvsBlameConsumer

use of org.apache.maven.scm.provider.cvslib.command.blame.CvsBlameConsumer in project maven-scm by apache.

the class CvsJavaBlameCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected BlameScmResult executeCvsCommand(Commandline cl, CvsScmProviderRepository repository) {
    CvsLogListener logListener = new CvsLogListener();
    CvsBlameConsumer consumer = new CvsBlameConsumer(getLogger());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new BlameScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
        }
        BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
        String line;
        while ((line = stream.readLine()) != null) {
            consumer.consumeLine(line);
        }
    } catch (Exception e) {
        getLogger().error(e);
        return new BlameScmResult(cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false);
    }
    return new BlameScmResult(cl.toString(), consumer.getLines());
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) BufferedReader(java.io.BufferedReader) CvsBlameConsumer(org.apache.maven.scm.provider.cvslib.command.blame.CvsBlameConsumer)

Example 2 with CvsBlameConsumer

use of org.apache.maven.scm.provider.cvslib.command.blame.CvsBlameConsumer in project maven-scm by apache.

the class CvsExeBlameCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected BlameScmResult executeCvsCommand(Commandline cl, CvsScmProviderRepository repository) throws ScmException {
    CvsBlameConsumer consumer = new CvsBlameConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing cvs command.", ex);
    }
    if (exitCode != 0) {
        return new BlameScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new BlameScmResult(cl.toString(), consumer.getLines());
}
Also used : ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) CvsBlameConsumer(org.apache.maven.scm.provider.cvslib.command.blame.CvsBlameConsumer)

Aggregations

BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)2 CvsBlameConsumer (org.apache.maven.scm.provider.cvslib.command.blame.CvsBlameConsumer)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1 ScmException (org.apache.maven.scm.ScmException)1 CvsLogListener (org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener)1 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)1 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)1