Search in sources :

Example 16 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class PerforceEditCommand method executeEditCommand.

/**
 * {@inheritDoc}
 */
@Override
protected ScmResult executeEditCommand(ScmProviderRepository repo, ScmFileSet files) throws ScmException {
    Commandline cl = createCommandLine((PerforceScmProviderRepository) repo, files.getBasedir(), files);
    PerforceEditConsumer consumer = new PerforceEditConsumer();
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug(PerforceScmProvider.clean("Executing " + cl.toString()));
        }
        CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
        int exitCode = CommandLineUtils.executeCommandLine(cl, consumer, err);
        if (exitCode != 0) {
            String cmdLine = CommandLineUtils.toString(cl.getCommandline());
            StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput());
            msg.append('\n');
            msg.append("Command line was:" + cmdLine);
            throw new CommandLineException(msg.toString());
        }
    } catch (CommandLineException e) {
        if (getLogger().isErrorEnabled()) {
            getLogger().error("CommandLineException " + e.getMessage(), e);
        }
    }
    if (consumer.isSuccess()) {
        return new EditScmResult(cl.toString(), consumer.getEdits());
    }
    return new EditScmResult(cl.toString(), "Unable to edit file(s)", consumer.getErrorMessage(), false);
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 17 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class PerforceScmProvider method edit.

protected EditScmResult edit(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    PerforceEditCommand command = new PerforceEditCommand();
    command.setLogger(getLogger());
    return (EditScmResult) command.execute(repository, fileSet, params);
}
Also used : PerforceEditCommand(org.apache.maven.scm.provider.perforce.command.edit.PerforceEditCommand) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult)

Aggregations

EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)17 UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)5 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)4 Commandline (org.codehaus.plexus.util.cli.Commandline)4 ScmException (org.apache.maven.scm.ScmException)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ScmFile (org.apache.maven.scm.ScmFile)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)1 LinkedList (java.util.LinkedList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 ClearCaseEditCommand (org.apache.maven.scm.provider.clearcase.command.edit.ClearCaseEditCommand)1 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)1 Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)1 IntegrityEditCommand (org.apache.maven.scm.provider.integrity.command.edit.IntegrityEditCommand)1 IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)1