Search in sources :

Example 21 with StatusScmResult

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);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmFileSet(org.apache.maven.scm.ScmFileSet) CategorisedElements(org.apache.maven.scm.provider.accurev.CategorisedElements) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFile(org.apache.maven.scm.ScmFile) ScmFileMatcher.scmFile(org.apache.maven.scm.ScmFileMatcher.scmFile) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 22 with StatusScmResult

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);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) BazaarStatusCommand(org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand)

Example 23 with StatusScmResult

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);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) VssStatusCommand(org.apache.maven.scm.provider.vss.commands.status.VssStatusCommand)

Example 24 with StatusScmResult

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);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) TfsStatusCommand(org.apache.maven.scm.provider.tfs.command.TfsStatusCommand)

Example 25 with StatusScmResult

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());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) TfsScmProviderRepository(org.apache.maven.scm.provider.tfs.TfsScmProviderRepository) ChangedFileConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ChangedFileConsumer) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer) ScmFile(org.apache.maven.scm.ScmFile)

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