Search in sources :

Example 31 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class ClearCaseAddCommand method executeAddCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeAddCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet, String string, boolean b) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing add command...");
    }
    Commandline cl = createCommandLine(scmFileSet);
    ClearCaseAddConsumer consumer = new ClearCaseAddConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        // First we need to 'check out' the current directory
        Commandline checkoutCurrentDirCommandLine = ClearCaseEditCommand.createCheckoutCurrentDirCommandLine(scmFileSet);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + checkoutCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkoutCurrentDirCommandLine.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(checkoutCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
        if (exitCode == 0) {
            // Then we add the file
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
            }
            exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
            if (exitCode == 0) {
                // Then we check in the current directory again.
                Commandline checkinCurrentDirCommandLine = ClearCaseEditCommand.createCheckinCurrentDirCommandLine(scmFileSet);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Executing: " + checkinCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkinCurrentDirCommandLine.toString());
                }
                exitCode = CommandLineUtils.executeCommandLine(checkinCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
            }
        }
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getAddedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 32 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class HgStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
public StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    File workingDir = fileSet.getBasedir();
    HgStatusConsumer consumer = new HgStatusConsumer(getLogger(), workingDir);
    String[] statusCmd = new String[] { HgCommandConstants.STATUS_CMD };
    ScmResult result = HgUtils.execute(consumer, getLogger(), workingDir, statusCmd);
    return new StatusScmResult(consumer.getStatus(), result);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmResult(org.apache.maven.scm.ScmResult) StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) File(java.io.File)

Example 33 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class CvsJavaStatusCommand method executeCvsCommand.

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

Example 34 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class JazzStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
public StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing status command...");
    }
    JazzStatusConsumer statusConsumer = new JazzStatusConsumer(repo, getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    JazzScmCommand statusCmd = createStatusCommand(repo, fileSet);
    int status = statusCmd.execute(statusConsumer, errConsumer);
    if (status != 0) {
        return new StatusScmResult(statusCmd.getCommandString(), "Error code for Jazz SCM status command - " + status, errConsumer.getOutput(), false);
    }
    if (getLogger().isDebugEnabled()) {
        if (!statusConsumer.getChangedFiles().isEmpty()) {
            getLogger().debug("Iterating over \"Status\" results");
            for (ScmFile file : statusConsumer.getChangedFiles()) {
                getLogger().debug(file.getPath() + " : " + file.getStatus());
            }
        } else {
            getLogger().debug("There are no differences");
        }
    }
    return new StatusScmResult(statusCmd.getCommandString(), statusConsumer.getChangedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) ScmFile(org.apache.maven.scm.ScmFile)

Example 35 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class StarteamScmProvider method status.

/**
 * {@inheritDoc}
 */
public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    fileSet = fixUpScmFileSetAbsoluteFilePath(fileSet);
    StarteamStatusCommand command = new StarteamStatusCommand();
    command.setLogger(getLogger());
    return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) StarteamStatusCommand(org.apache.maven.scm.provider.starteam.command.status.StarteamStatusCommand)

Aggregations

StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)40 ScmFile (org.apache.maven.scm.ScmFile)15 ScmException (org.apache.maven.scm.ScmException)14 File (java.io.File)12 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)9 Commandline (org.codehaus.plexus.util.cli.Commandline)9 ArrayList (java.util.ArrayList)6 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)6 ScmResult (org.apache.maven.scm.ScmResult)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)3 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)3 JazzStatusCommand (org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand)3 ScmRepository (org.apache.maven.scm.repository.ScmRepository)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 CommandParameters (org.apache.maven.scm.CommandParameters)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 CategorisedElements (org.apache.maven.scm.provider.accurev.CategorisedElements)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 BazaarStatusCommand (org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand)2