Search in sources :

Example 11 with DiffScmResult

use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.

the class StarteamDiffCommand method executeDiffCommand.

// ----------------------------------------------------------------------
// AbstractDiffCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected DiffScmResult executeDiffCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion) throws ScmException {
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    if (fileSet.getFileList().isEmpty()) {
        throw new ScmException("This provider doesn't support diff command on a subsets of a directory");
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamDiffConsumer consumer = new StarteamDiffConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    Commandline cl = createCommandLine(repository, fileSet, startVersion, endVersion);
    int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        return new DiffScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
    }
    return new DiffScmResult(cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) StarteamCommandLineUtils(org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Example 12 with DiffScmResult

use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.

the class BazaarScmProvider method diff.

/**
 * {@inheritDoc}
 */
public DiffScmResult diff(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    BazaarDiffCommand command = new BazaarDiffCommand();
    command.setLogger(getLogger());
    return (DiffScmResult) command.execute(repository, fileSet, parameters);
}
Also used : BazaarDiffCommand(org.apache.maven.scm.provider.bazaar.command.diff.BazaarDiffCommand) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Example 13 with DiffScmResult

use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.

the class IntegrityScmProvider method diff.

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

Example 14 with DiffScmResult

use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.

the class HgDiffCommand method executeDiffCommand.

/**
 * {@inheritDoc}
 */
protected DiffScmResult executeDiffCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) throws ScmException {
    String[] diffCmd;
    if (startRevision != null && !StringUtils.isEmpty(startRevision.getName())) {
        String revArg = startRevision.getName();
        if (endRevision != null && !StringUtils.isEmpty(endRevision.getName())) {
            revArg += ".." + endRevision;
        }
        diffCmd = new String[] { HgCommandConstants.DIFF_CMD, HgCommandConstants.REVISION_OPTION, revArg };
    } else {
        diffCmd = new String[] { HgCommandConstants.DIFF_CMD };
    }
    diffCmd = HgUtils.expandCommandLine(diffCmd, fileSet);
    HgDiffConsumer consumer = new HgDiffConsumer(getLogger(), fileSet.getBasedir());
    ScmResult result = HgUtils.execute(consumer, getLogger(), fileSet.getBasedir(), diffCmd);
    return new DiffScmResult(consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result);
}
Also used : ScmResult(org.apache.maven.scm.ScmResult) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Example 15 with DiffScmResult

use of org.apache.maven.scm.command.diff.DiffScmResult in project maven-scm by apache.

the class CvsJavaDiffCommand method executeCvsCommand.

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

Aggregations

DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)21 ScmException (org.apache.maven.scm.ScmException)6 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)6 Commandline (org.codehaus.plexus.util.cli.Commandline)5 ScmFile (org.apache.maven.scm.ScmFile)4 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)4 File (java.io.File)3 ScmResult (org.apache.maven.scm.ScmResult)3 ScmRepository (org.apache.maven.scm.repository.ScmRepository)3 IOException (java.io.IOException)2 ScmFileSet (org.apache.maven.scm.ScmFileSet)2 ScmProvider (org.apache.maven.scm.provider.ScmProvider)2 CvsDiffConsumer (org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer)2 GitDiffConsumer (org.apache.maven.scm.provider.git.command.diff.GitDiffConsumer)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1