Search in sources :

Example 1 with CvsChangeLogConsumer

use of org.apache.maven.scm.provider.cvslib.command.changelog.CvsChangeLogConsumer in project maven-scm by apache.

the class CvsExeChangeLogCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ChangeLogScmResult executeCvsCommand(Commandline cl, Date startDate, Date endDate, ScmVersion startVersion, ScmVersion endVersion, String datePattern) throws ScmException {
    CvsChangeLogConsumer consumer = new CvsChangeLogConsumer(getLogger(), datePattern);
    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 ChangeLogScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    ChangeLogSet changeLogSet = new ChangeLogSet(consumer.getModifications(), startDate, endDate);
    changeLogSet.setStartVersion(startVersion);
    changeLogSet.setEndVersion(endVersion);
    return new ChangeLogScmResult(cl.toString(), changeLogSet);
}
Also used : CvsChangeLogConsumer(org.apache.maven.scm.provider.cvslib.command.changelog.CvsChangeLogConsumer) ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 2 with CvsChangeLogConsumer

use of org.apache.maven.scm.provider.cvslib.command.changelog.CvsChangeLogConsumer in project maven-scm by apache.

the class CvsJavaChangeLogCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ChangeLogScmResult executeCvsCommand(Commandline cl, Date startDate, Date endDate, ScmVersion startVersion, ScmVersion endVersion, String datePattern) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsChangeLogConsumer consumer = new CvsChangeLogConsumer(getLogger(), datePattern);
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new ChangeLogScmResult(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 ChangeLogScmResult(cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false);
    }
    ChangeLogSet changeLogSet = new ChangeLogSet(consumer.getModifications(), startDate, endDate);
    changeLogSet.setStartVersion(startVersion);
    changeLogSet.setEndVersion(endVersion);
    return new ChangeLogScmResult(cl.toString(), changeLogSet);
}
Also used : CvsChangeLogConsumer(org.apache.maven.scm.provider.cvslib.command.changelog.CvsChangeLogConsumer) CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) ScmException(org.apache.maven.scm.ScmException)

Aggregations

ScmException (org.apache.maven.scm.ScmException)2 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)2 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)2 CvsChangeLogConsumer (org.apache.maven.scm.provider.cvslib.command.changelog.CvsChangeLogConsumer)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