Search in sources :

Example 11 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class CvsCheckoutCommandTest method testCheckOutWithTag.

/**
 * @todo move this test to the TCK - checkout with "revision", then have one for tag as well.
 */
public void testCheckOutWithTag() throws Exception {
    if (!isSystemCmd(CvsScmTestUtils.CVS_COMMAND_LINE)) {
        System.err.println("'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored " + getName() + ".");
        return;
    }
    ScmManager scmManager = getScmManager();
    @SuppressWarnings("deprecation") CheckOutScmResult result = scmManager.getProviderByRepository(getScmRepository()).checkOut(getScmRepository(), getScmFileSet(), "MAVEN_1_0");
    if (!result.isSuccess()) {
        fail(result.getProviderMessage() + "\n" + result.getCommandOutput());
    }
    List<ScmFile> files = result.getCheckedOutFiles();
    assertNotNull(files);
    assertEquals(1, files.size());
    File mavenUtils = assertCheckedOutFile(files, 0, "/src/java/org/apache/maven/MavenUtils.java", ScmFileStatus.UPDATED);
    assertBetween(38403, 39511, mavenUtils.length());
}
Also used : ScmManager(org.apache.maven.scm.manager.ScmManager) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 12 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class BootstrapMojo method execute.

/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException {
    super.execute();
    if (this.getCheckoutResult() != null) {
        ScmResult checkoutResult = this.getCheckoutResult();
        // At the time of useExport feature is requested only SVN and and CVS have export command implemented
        // we will deal with this as more user using this feature specially clearcase where we need to
        // add relativePathProjectDirectory support to ExportScmResult
        String relativePathProjectDirectory = "";
        if (checkoutResult instanceof CheckOutScmResult) {
            relativePathProjectDirectory = ((CheckOutScmResult) checkoutResult).getRelativePathProjectDirectory();
        }
        runGoals(relativePathProjectDirectory);
    }
}
Also used : CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmResult(org.apache.maven.scm.ScmResult) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 13 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class AccuRevScmProvider method checkout.

@Override
protected CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    // workaround deprecated behaviour
    // TODO pull up to AbstractScmProvider
    AccuRevScmProviderRepository accuRevRepo = (AccuRevScmProviderRepository) repository;
    if (!repository.isPersistCheckout() && accuRevRepo.shouldUseExportForNonPersistentCheckout()) {
        ExportScmResult result = export(repository, fileSet, parameters);
        if (result.isSuccess()) {
            return new CheckOutScmResult(result.getCommandLine(), result.getExportedFiles(), accuRevRepo.getExportRelativePath());
        } else {
            return new CheckOutScmResult(result.getCommandLine(), result.getProviderMessage(), result.getCommandOutput(), false);
        }
    }
    AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
    return command.checkout(repository, fileSet, parameters);
}
Also used : AccuRevCheckOutCommand(org.apache.maven.scm.provider.accurev.command.checkout.AccuRevCheckOutCommand) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 14 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class VssCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkout command...");
    }
    VssScmProviderRepository repo = (VssScmProviderRepository) repository;
    Commandline cl = buildCmdLine(repo, fileSet, version);
    VssCheckOutConsumer consumer = new VssCheckOutConsumer(repo, getLogger());
    // TODO handle deleted files from VSS
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
    }
    exitCode = VssCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        String error = stderr.getOutput();
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("VSS returns error: [" + error + "] return code: [" + exitCode + "]");
        }
        if (error.indexOf("A writable copy of") < 0) {
            return new CheckOutScmResult(cl.toString(), "The vss command failed.", error, false);
        }
        // print out the writable copy for manual handling
        if (getLogger().isWarnEnabled()) {
            getLogger().warn(error);
        }
    }
    return new CheckOutScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) VssScmProviderRepository(org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository) VssCommandLineUtils(org.apache.maven.scm.provider.vss.commands.VssCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 15 with CheckOutScmResult

use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.

the class TfsScmProvider method checkout.

protected CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    TfsCheckOutCommand command = new TfsCheckOutCommand();
    command.setLogger(getLogger());
    return (CheckOutScmResult) command.execute(repository, fileSet, parameters);
}
Also used : TfsCheckOutCommand(org.apache.maven.scm.provider.tfs.command.TfsCheckOutCommand) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Aggregations

CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)57 File (java.io.File)24 ScmFileSet (org.apache.maven.scm.ScmFileSet)20 ScmFile (org.apache.maven.scm.ScmFile)14 ScmException (org.apache.maven.scm.ScmException)11 ScmTag (org.apache.maven.scm.ScmTag)9 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)9 Commandline (org.codehaus.plexus.util.cli.Commandline)8 Test (org.junit.Test)8 CommandParameters (org.apache.maven.scm.CommandParameters)7 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)7 IOException (java.io.IOException)6 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)6 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)6 ScmManager (org.apache.maven.scm.manager.ScmManager)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)5 ArrayList (java.util.ArrayList)4 ScmResult (org.apache.maven.scm.ScmResult)4 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)3