use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class AccuRevStatusCommandTest method testStatus.
@Test
public void testStatus() throws Exception {
final ScmFileSet testFileSet = getScmFileSet();
File keptFile = new File("kept/file");
File keptAdded = new File("kept/added");
// this is the special one, it is returned by both the kept and defunct stat calls, so the command
// needs to filter it out.
File keptDefunct = new File("kept/defunct");
File modifiedFile = new File("modified/file");
File modifiedAdded = new File("modified/added");
File missingFile = new File("missing/file");
File externalFile = new File("external/file");
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.DEFUNCT))).thenReturn(Arrays.asList(keptDefunct));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.MODIFIED))).thenReturn(Arrays.asList(modifiedFile, modifiedAdded));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.KEPT))).thenReturn(Arrays.asList(keptDefunct, keptFile, keptAdded));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.MISSING))).thenReturn(Arrays.asList(missingFile));
when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.EXTERNAL))).thenReturn(Arrays.asList(externalFile));
CategorisedElements catElems = new CategorisedElements();
catElems.getMemberElements().addAll(Arrays.asList(modifiedFile, keptFile));
catElems.getNonMemberElements().addAll(Arrays.asList(modifiedAdded, keptAdded));
when(accurev.statBackingStream(eq(basedir), (Collection<File>) argThat(hasItems(modifiedFile, modifiedAdded, keptFile, keptAdded)))).thenReturn(catElems);
AccuRevStatusCommand command = new AccuRevStatusCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
StatusScmResult result = command.status(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(true));
assertThat(result.getChangedFiles().size(), is(7));
assertThat((List<ScmFile>) result.getChangedFiles(), not(Matchers.<ScmFile>hasItem(scmFile("kept/defunct", ScmFileStatus.MODIFIED))));
assertHasScmFile(result.getChangedFiles(), "kept/file", ScmFileStatus.MODIFIED);
assertHasScmFile(result.getChangedFiles(), "kept/added", ScmFileStatus.ADDED);
assertHasScmFile(result.getChangedFiles(), "kept/defunct", ScmFileStatus.DELETED);
assertHasScmFile(result.getChangedFiles(), "modified/file", ScmFileStatus.MODIFIED);
assertHasScmFile(result.getChangedFiles(), "modified/added", ScmFileStatus.ADDED);
assertHasScmFile(result.getChangedFiles(), "missing/file", ScmFileStatus.MISSING);
assertHasScmFile(result.getChangedFiles(), "external/file", ScmFileStatus.UNKNOWN);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class BazaarScmProvider method status.
/**
* {@inheritDoc}
*/
public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
BazaarStatusCommand command = new BazaarStatusCommand();
command.setLogger(getLogger());
return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class VssScmProvider method status.
/**
* {@inheritDoc}
*/
public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
VssStatusCommand command = new VssStatusCommand();
command.setLogger(getLogger());
return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class TfsScmProvider method status.
protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
TfsStatusCommand command = new TfsStatusCommand();
command.setLogger(getLogger());
return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class TfsStatusCommand method executeStatusCommand.
protected StatusScmResult executeStatusCommand(ScmProviderRepository r, ScmFileSet f) throws ScmException {
TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r;
TfsCommand command = createCommand(tfsRepo, f);
ChangedFileConsumer out = new ChangedFileConsumer(getLogger());
ErrorStreamConsumer err = new ErrorStreamConsumer();
int status = command.execute(out, err);
if (status != 0 || err.hasBeenFed()) {
return new StatusScmResult(command.getCommandString(), "Error code for TFS status command - " + status, err.getOutput(), false);
}
Iterator<ScmFile> iter = out.getChangedFiles().iterator();
getLogger().debug("Iterating");
while (iter.hasNext()) {
ScmFile file = (ScmFile) iter.next();
getLogger().debug(file.getPath() + ":" + file.getStatus());
}
return new StatusScmResult(command.getCommandString(), out.getChangedFiles());
}
Aggregations