Search in sources :

Example 1 with CvsDiffConsumer

use of org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer in project maven-scm by apache.

the class CvsExeDiffCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected DiffScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsDiffConsumer consumer = new CvsDiffConsumer(getLogger(), cl.getWorkingDirectory());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    try {
        CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    return new DiffScmResult(cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
}
Also used : CvsDiffConsumer(org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer) ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Example 2 with CvsDiffConsumer

use of org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer in project maven-scm by apache.

the class CvsJavaDiffCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected DiffScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsDiffConsumer consumer = new CvsDiffConsumer(getLogger(), cl.getWorkingDirectory());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new DiffScmResult(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) {
        e.printStackTrace();
        return new DiffScmResult(cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false);
    }
    return new DiffScmResult(cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
}
Also used : CvsDiffConsumer(org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer) CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult) ScmException(org.apache.maven.scm.ScmException)

Aggregations

ScmException (org.apache.maven.scm.ScmException)2 DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)2 CvsDiffConsumer (org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)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