Search in sources :

Example 6 with BlameScmResult

use of org.apache.maven.scm.command.blame.BlameScmResult in project maven-scm by apache.

the class HgBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    String[] cmd = new String[] { // list the author
    BLAME_CMD, // list the author
    "--user", // list the date
    "--date", // list the global revision number
    "--changeset", filename };
    HgBlameConsumer consumer = new HgBlameConsumer(getLogger());
    ScmResult result = HgUtils.execute(consumer, getLogger(), workingDirectory.getBasedir(), cmd);
    return new BlameScmResult(consumer.getLines(), result);
}
Also used : ScmResult(org.apache.maven.scm.ScmResult) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult)

Example 7 with BlameScmResult

use of org.apache.maven.scm.command.blame.BlameScmResult in project maven-scm by apache.

the class ClearCaseScmProvider method blame.

/**
 * {@inheritDoc}
 */
protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    ClearCaseBlameCommand command = new ClearCaseBlameCommand();
    command.setLogger(getLogger());
    return (BlameScmResult) command.execute(repository, fileSet, parameters);
}
Also used : ClearCaseBlameCommand(org.apache.maven.scm.provider.clearcase.command.blame.ClearCaseBlameCommand) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult)

Example 8 with BlameScmResult

use of org.apache.maven.scm.command.blame.BlameScmResult in project maven-scm by apache.

the class ClearCaseBlameCommand method executeBlameCommand.

public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing blame command...");
    }
    Commandline cl = createCommandLine(workingDirectory.getBasedir(), filename);
    ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        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 cleartool command failed.", stderr.getOutput(), false);
    }
    return new BlameScmResult(cl.toString(), consumer.getLines());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 9 with BlameScmResult

use of org.apache.maven.scm.command.blame.BlameScmResult 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 10 with BlameScmResult

use of org.apache.maven.scm.command.blame.BlameScmResult in project maven-scm by apache.

the class TfsScmProvider method blame.

protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    TfsBlameCommand command = new TfsBlameCommand();
    command.setLogger(getLogger());
    return (BlameScmResult) command.execute(repository, fileSet, parameters);
}
Also used : TfsBlameCommand(org.apache.maven.scm.provider.tfs.command.blame.TfsBlameCommand) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult)

Aggregations

BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)24 ScmException (org.apache.maven.scm.ScmException)7 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)7 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)6 Commandline (org.codehaus.plexus.util.cli.Commandline)6 BlameLine (org.apache.maven.scm.command.blame.BlameLine)5 File (java.io.File)3 ScmResult (org.apache.maven.scm.ScmResult)3 Date (java.util.Date)2 CommandParameters (org.apache.maven.scm.CommandParameters)2 ScmFileSet (org.apache.maven.scm.ScmFileSet)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 ArrayList (java.util.ArrayList)1 BlameScmRequest (org.apache.maven.scm.command.blame.BlameScmRequest)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 ScmManager (org.apache.maven.scm.manager.ScmManager)1 ScmProvider (org.apache.maven.scm.provider.ScmProvider)1