Search in sources :

Example 1 with CvsLogListener

use of org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener in project maven-scm by apache.

the class CvsJavaRemoveCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected RemoveScmResult executeCvsCommand(Commandline cl, List<ScmFile> removedFiles) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new RemoveScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
        }
        BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
        if (getLogger().isDebugEnabled()) {
            String line;
            while ((line = stream.readLine()) != null) {
                getLogger().debug(line);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return new RemoveScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
    }
    return new RemoveScmResult(cl.toString(), removedFiles);
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) ScmException(org.apache.maven.scm.ScmException)

Example 2 with CvsLogListener

use of org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener in project maven-scm by apache.

the class CvsJavaCheckInCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCvsCommand(Commandline cl, CvsScmProviderRepository repository, File messageFile) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsCheckInConsumer consumer = new CvsCheckInConsumer(repository.getPath(), getLogger());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new CheckInScmResult(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 CheckInScmResult(cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false);
    } finally {
        try {
            FileUtils.forceDelete(messageFile);
        } catch (IOException ex) {
        // ignore
        }
    }
    return new CheckInScmResult(cl.toString(), consumer.getCheckedInFiles());
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) CvsCheckInConsumer(org.apache.maven.scm.provider.cvslib.command.checkin.CvsCheckInConsumer) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) IOException(java.io.IOException) ScmException(org.apache.maven.scm.ScmException)

Example 3 with CvsLogListener

use of org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener in project maven-scm by apache.

the class CvsJavaListCommand method executeCvsCommand.

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

Example 4 with CvsLogListener

use of org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener 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 5 with CvsLogListener

use of org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener 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

BufferedReader (java.io.BufferedReader)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 InputStreamReader (java.io.InputStreamReader)12 CvsLogListener (org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener)12 ScmException (org.apache.maven.scm.ScmException)11 CvsUpdateConsumer (org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer)2 IOException (java.io.IOException)1 BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)1 BranchScmResult (org.apache.maven.scm.command.branch.BranchScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)1 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)1 ListScmResult (org.apache.maven.scm.command.list.ListScmResult)1 RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)1 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)1