Search in sources :

Example 6 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class CvsJavaRemoveCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected RemoveScmResult executeCvsCommand(Commandline cl, List<ScmFile> removedFiles) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new RemoveScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
        }
        BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
        if (getLogger().isDebugEnabled()) {
            String line;
            while ((line = stream.readLine()) != null) {
                getLogger().debug(line);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return new RemoveScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
    }
    return new RemoveScmResult(cl.toString(), removedFiles);
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) ScmException(org.apache.maven.scm.ScmException)

Example 7 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class CvsExeRemoveCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected RemoveScmResult executeCvsCommand(Commandline cl, List<ScmFile> removedFiles) throws ScmException {
    CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer();
    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);
    }
    // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses?
    if (exitCode != 0) {
        return new RemoveScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new RemoveScmResult(cl.toString(), removedFiles);
}
Also used : ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 8 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class AccuRevRemoveCommand method executeAccurevCommand.

@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    String message = parameters.getString(CommandParameter.MESSAGE, "");
    File basedir = fileSet.getBasedir();
    List<File> relativeFiles = fileSet.getFileList();
    final List<File> removedFiles = accuRev.defunct(basedir, relativeFiles, message);
    if (removedFiles != null) {
        List<ScmFile> resultFiles = getScmFiles(removedFiles, ScmFileStatus.DELETED);
        return new RemoveScmResult(accuRev.getCommandLines(), resultFiles);
    } else {
        return new RemoveScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
    }
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Example 9 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class AccuRevRemoveCommandTest method testRemove.

@Test
public void testRemove() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(basedir, new File("src/main/java/Foo.java"));
    List<File> removedFiles = Collections.singletonList(new File("removed/file"));
    when(accurev.defunct(basedir, testFileSet.getFileList(), "A deleted file")).thenReturn(removedFiles);
    AccuRevRemoveCommand command = new AccuRevRemoveCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A deleted file");
    RemoveScmResult result = command.remove(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getRemovedFiles().size(), is(1));
    assertHasScmFile(result.getRemovedFiles(), "removed/file", ScmFileStatus.DELETED);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 10 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class BazaarScmProvider method remove.

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

Aggregations

RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)20 File (java.io.File)7 ScmException (org.apache.maven.scm.ScmException)6 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 Commandline (org.codehaus.plexus.util.cli.Commandline)4 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)3 CommandParameters (org.apache.maven.scm.CommandParameters)2 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)2 ScmResult (org.apache.maven.scm.ScmResult)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 ScmRepository (org.apache.maven.scm.repository.ScmRepository)2 Test (org.junit.Test)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1