Search in sources :

Example 46 with CheckOutScmResult

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

the class JazzCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion, boolean recursive, boolean shallow) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing checkout command...");
    }
    JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
    JazzScmCommand checkoutCmd = createJazzLoadCommand(jazzRepo, fileSet, scmVersion);
    JazzCheckOutConsumer checkoutConsumer = new JazzCheckOutConsumer(repo, getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    int status = checkoutCmd.execute(checkoutConsumer, errConsumer);
    if (status != 0) {
        return new CheckOutScmResult(checkoutCmd.getCommandString(), "Error code for Jazz SCM checkout (load) command - " + status, errConsumer.getOutput(), false);
    }
    return new CheckOutScmResult(checkoutCmd.getCommandString(), checkoutConsumer.getCheckedOutFiles());
}
Also used : ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Example 47 with CheckOutScmResult

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

the class JazzScmProvider method checkout.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    getLogger().debug("JazzScmProvider:checkout()");
    JazzCheckOutCommand command = new JazzCheckOutCommand();
    command.setLogger(getLogger());
    return (CheckOutScmResult) command.execute(repository, fileSet, parameters);
}
Also used : JazzCheckOutCommand(org.apache.maven.scm.provider.jazz.command.checkout.JazzCheckOutCommand) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 48 with CheckOutScmResult

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

the class SvnCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
    String url = repository.getUrl();
    if (version != null && StringUtils.isNotEmpty(version.getName())) {
        if (version instanceof ScmTag) {
            url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version);
        } else if (version instanceof ScmBranch) {
            url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version);
        }
    }
    url = SvnCommandUtils.fixUrl(url, repository.getUser());
    Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive);
    SvnCheckOutConsumer consumer = new SvnCheckOutConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
        }
    }
    try {
        exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new CheckOutScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
    }
    return new CheckOutScmResult(cl.toString(), Integer.toString(consumer.getRevision()), consumer.getCheckedOutFiles());
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) ScmTag(org.apache.maven.scm.ScmTag) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 49 with CheckOutScmResult

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

the class LocalCheckOutCommandTckTest method testMetadata.

/**
 * Tests that the metadata file .maven-scm-local is written correctly
 */
public void testMetadata() throws Exception {
    FileUtils.deleteDirectory(getWorkingCopy());
    CheckOutScmResult result = checkOut(getWorkingCopy(), getScmRepository());
    assertResultIsSuccess(result);
    List<ScmFile> checkedOutFiles = result.getCheckedOutFiles();
    assertEquals(4, checkedOutFiles.size());
    // ----------------------------------------------------------------------
    // Assert metadata file
    // ----------------------------------------------------------------------
    File metadataFile = new File(getWorkingCopy(), ".maven-scm-local");
    assertTrue("Expected metadata file .maven-scm-local does not exist", metadataFile.exists());
    Reader reader = new FileReader(metadataFile);
    LocalScmMetadata metadata;
    try {
        metadata = new LocalScmMetadataXpp3Reader().read(reader);
    } finally {
        IOUtil.close(reader);
    }
    File root = new File(getRepositoryRoot() + "/" + module);
    @SuppressWarnings("unchecked") List<String> fileNames = FileUtils.getFileNames(root, "**", null, false);
    assertEquals(fileNames, metadata.getRepositoryFileNames());
}
Also used : LocalScmMetadata(org.apache.maven.scm.provider.local.metadata.LocalScmMetadata) LocalScmMetadataXpp3Reader(org.apache.maven.scm.provider.local.metadata.io.xpp3.LocalScmMetadataXpp3Reader) FileReader(java.io.FileReader) Reader(java.io.Reader) LocalScmMetadataXpp3Reader(org.apache.maven.scm.provider.local.metadata.io.xpp3.LocalScmMetadataXpp3Reader) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) FileReader(java.io.FileReader) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 50 with CheckOutScmResult

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

the class PerforceScmProvider method checkout.

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

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