Search in sources :

Example 1 with BlameScmResult

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

the class BazaarBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    String[] cmd = new String[] { // Show annotations on all lines
    BLAME_CMD, // Show annotations on all lines
    "--all", // Show commit date in annotations
    "--long", filename };
    BazaarBlameConsumer consumer = new BazaarBlameConsumer(getLogger());
    ScmResult result = BazaarUtils.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 2 with BlameScmResult

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

the class SvnBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    Commandline cl = createCommandLine((SvnScmProviderRepository) repo, workingDirectory.getBasedir(), filename);
    SvnBlameConsumer consumer = new SvnBlameConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
        }
    }
    int exitCode;
    try {
        exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new BlameScmResult(cl.toString(), "The svn 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) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 3 with BlameScmResult

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

the class PerforceBlameCommand method executeBlameCommand.

public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    // Call annotate command
    PerforceScmProviderRepository p4repo = (PerforceScmProviderRepository) repo;
    String clientspec = PerforceScmProvider.getClientspecName(getLogger(), p4repo, workingDirectory.getBasedir());
    Commandline cl = createCommandLine((PerforceScmProviderRepository) repo, workingDirectory.getBasedir(), filename, clientspec);
    PerforceBlameConsumer blameConsumer = new PerforceBlameConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        exitCode = CommandLineUtils.executeCommandLine(cl, blameConsumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new BlameScmResult(cl.toString(), "The perforce command failed.", stderr.getOutput(), false);
    }
    // Call filelog command
    cl = createFilelogCommandLine((PerforceScmProviderRepository) repo, workingDirectory.getBasedir(), filename, clientspec);
    PerforceFilelogConsumer filelogConsumer = new PerforceFilelogConsumer(getLogger());
    try {
        exitCode = CommandLineUtils.executeCommandLine(cl, filelogConsumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new BlameScmResult(cl.toString(), "The perforce command failed.", stderr.getOutput(), false);
    }
    // Combine results
    List<BlameLine> lines = blameConsumer.getLines();
    for (int i = 0; i < lines.size(); i++) {
        BlameLine line = lines.get(i);
        String revision = line.getRevision();
        line.setAuthor(filelogConsumer.getAuthor(revision));
        line.setDate(filelogConsumer.getDate(revision));
    }
    return new BlameScmResult(cl.toString(), lines);
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) BlameLine(org.apache.maven.scm.command.blame.BlameLine) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository)

Example 4 with BlameScmResult

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

the class IntegrityScmProvider method blame.

/**
 * Maps to si annotate
 */
@Override
protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    IntegrityBlameCommand command = new IntegrityBlameCommand();
    command.setLogger(getLogger());
    return (BlameScmResult) command.execute(repository, fileSet, params);
}
Also used : IntegrityBlameCommand(org.apache.maven.scm.provider.integrity.command.blame.IntegrityBlameCommand) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult)

Example 5 with BlameScmResult

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

the class HgScmProvider method blame.

/**
 * {@inheritDoc}
 */
protected BlameScmResult blame(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    HgBlameCommand command = new HgBlameCommand();
    command.setLogger(getLogger());
    return (BlameScmResult) command.execute(repository, fileSet, parameters);
}
Also used : HgBlameCommand(org.apache.maven.scm.provider.hg.command.blame.HgBlameCommand) 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