Search in sources :

Example 26 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class StatusCommandTckTest method testStatusCommand.

public void testStatusCommand() throws Exception {
    ScmRepository repository = makeScmRepository(getScmUrl());
    checkOut(getUpdatingCopy(), repository);
    // ----------------------------------------------------------------------
    // Change the files
    // ----------------------------------------------------------------------
    /*
         * readme.txt is changed (changed file in the root directory)
         * project.xml is added (added file in the root directory)
         */
    // /readme.txt
    this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository());
    ScmTestCase.makeFile(getWorkingCopy(), "/readme.txt", "changed readme.txt");
    // /project.xml
    ScmTestCase.makeFile(getWorkingCopy(), "/project.xml", "changed project.xml");
    addToWorkingTree(getWorkingCopy(), new File("project.xml"), getScmRepository());
    commit(getWorkingCopy(), getScmRepository());
    // /pom.xml
    this.edit(getUpdatingCopy(), "pom.xml", null, repository);
    ScmTestCase.makeFile(getUpdatingCopy(), "/pom.xml", "changed pom.xml");
    // /src/test/java/org
    ScmTestCase.makeDirectory(getUpdatingCopy(), "/src/test/java/org");
    addToWorkingTree(getUpdatingCopy(), new File("src/test/java/org"), repository);
    // /src/main/java/org/Foo.java
    ScmTestCase.makeFile(getUpdatingCopy(), "/src/main/java/org/Foo.java");
    addToWorkingTree(getUpdatingCopy(), new File("src/main/java/org"), repository);
    // src/main/java/org/Foo.java
    addToWorkingTree(getUpdatingCopy(), new File("src/main/java/org/Foo.java"), repository);
    ScmManager scmManager = getScmManager();
    // ----------------------------------------------------------------------
    // Check status the project
    // src/main/java/org/Foo.java is added
    // /pom.xml is modified
    // check that readme and project.xml are not updated/created
    // ----------------------------------------------------------------------
    StatusScmResult result = scmManager.getProviderByUrl(getScmUrl()).status(repository, new ScmFileSet(getUpdatingCopy()));
    if (this.commitUpdateCopy()) {
        // this is needed for perforce so that teardown can remove its client workspace, no harm for cvs/svn/git
        commit(getUpdatingCopy(), repository);
    }
    assertNotNull("The command returned a null result.", result);
    assertResultIsSuccess(result);
    List<ScmFile> changedFiles = result.getChangedFiles();
    assertEquals("Expected 2 files in the updated files list " + changedFiles, 2, changedFiles.size());
    // ----------------------------------------------------------------------
    // Assert the files in the updated files list
    // ----------------------------------------------------------------------
    Iterator<ScmFile> files = new TreeSet<ScmFile>(changedFiles).iterator();
    ScmFile file = files.next();
    assertPath("/src/main/java/org/Foo.java", file.getPath());
    assertEquals(ScmFileStatus.ADDED, file.getStatus());
    file = files.next();
    assertPath("/pom.xml", file.getPath());
    assertEquals(ScmFileStatus.MODIFIED, file.getStatus());
    assertFile(getUpdatingCopy(), "/readme.txt");
    assertFalse("project.xml created incorrectly", new File(getUpdatingCopy(), "/project.xml").exists());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmManager(org.apache.maven.scm.manager.ScmManager) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 27 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class HgScmProvider method status.

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

Example 28 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class ClearCaseRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet, String string) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing remove command...");
    }
    Commandline cl = createCommandLine(getLogger(), scmFileSet);
    ClearCaseRemoveConsumer consumer = new ClearCaseRemoveConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        // First we need to 'check out' the current directory
        Commandline checkoutCurrentDirCommandLine = ClearCaseEditCommand.createCheckoutCurrentDirCommandLine(scmFileSet);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + checkoutCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkoutCurrentDirCommandLine.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(checkoutCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
        if (exitCode == 0) {
            // Then we add the file
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
            }
            exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
            if (exitCode == 0) {
                // Then we check in the current directory again.
                Commandline checkinCurrentDirCommandLine = ClearCaseEditCommand.createCheckinCurrentDirCommandLine(scmFileSet);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Executing: " + checkinCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkinCurrentDirCommandLine.toString());
                }
                exitCode = CommandLineUtils.executeCommandLine(checkinCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
            }
        }
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getRemovedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 29 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class ClearCaseUnEditCommand method executeUnEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing unedit command...");
    }
    Commandline cl = createCommandLine(getLogger(), fileSet);
    ClearCaseUnEditConsumer consumer = new ClearCaseUnEditConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getUnEditFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 30 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class ClearCaseScmProvider method status.

/**
 * {@inheritDoc}
 */
protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    ClearCaseStatusCommand command = new ClearCaseStatusCommand();
    command.setLogger(getLogger());
    return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ClearCaseStatusCommand(org.apache.maven.scm.provider.clearcase.command.status.ClearCaseStatusCommand)

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