Search in sources :

Example 16 with BlameScmResult

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

the class TfsBlameCommand method executeBlameCommand.

public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    Commandline cl = createCommandLine(workingDirectory.getBasedir(), filename);
    TfsBlameConsumer consumer = new TfsBlameConsumer(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 command.", ex);
    }
    if (exitCode != 0) {
        return new BlameScmResult(cl.toString(), "The tfs 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 17 with BlameScmResult

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

Example 18 with BlameScmResult

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

the class IntegrityBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
@Override
public BlameScmResult executeBlameCommand(ScmProviderRepository repository, ScmFileSet workingDirectory, String filename) throws ScmException {
    getLogger().info("Attempting to display blame results for file: " + filename);
    if (null == filename || filename.length() == 0) {
        throw new ScmException("A single filename is required to execute the blame command!");
    }
    BlameScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    // Since the si annotate command is not completely API ready, we will use the CLI for this command
    // Ensure shell 'si' client is connected.
    doShellConnect(iRepo, workingDirectory);
    result = doShellAnnotate(iRepo, workingDirectory, filename);
    return result;
}
Also used : ScmException(org.apache.maven.scm.ScmException) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)

Example 19 with BlameScmResult

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

the class JazzScmProvider method blame.

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

Example 20 with BlameScmResult

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

the class JazzBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet fileSet, String filename) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing blame command...");
    }
    JazzScmCommand blameCmd = createBlameCommand(repo, fileSet, filename);
    JazzBlameConsumer blameConsumer = new JazzBlameConsumer(repo, getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    int status = blameCmd.execute(blameConsumer, errConsumer);
    if (status != 0) {
        return new BlameScmResult(blameCmd.getCommandString(), "Error code for Jazz SCM blame command - " + status, errConsumer.getOutput(), false);
    }
    return new BlameScmResult(blameCmd.getCommandString(), blameConsumer.getLines());
}
Also used : ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand)

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