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);
}
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);
}
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);
}
}
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);
}
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);
}
Aggregations