Search in sources :

Example 26 with CheckOutScmResult

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

the class StarteamScmProvider method checkout.

/**
 * {@inheritDoc}
 */
public CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    fileSet = fixUpScmFileSetAbsoluteFilePath(fileSet);
    StarteamCheckOutCommand command = new StarteamCheckOutCommand();
    command.setLogger(getLogger());
    return (CheckOutScmResult) command.execute(repository, fileSet, parameters);
}
Also used : CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) StarteamCheckOutCommand(org.apache.maven.scm.provider.starteam.command.checkout.StarteamCheckOutCommand)

Example 27 with CheckOutScmResult

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

the class SynergyCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    if (fileSet.getFileList().size() != 0) {
        throw new ScmException("This provider doesn't support checking out subsets of a project");
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkout command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(fileSet.toString());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    File waPath;
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec != null) {
            if (getLogger().isInfoEnabled()) {
                getLogger().info("A working project already exists [" + projectSpec + "].");
            }
            SynergyUtil.synchronize(getLogger(), projectSpec, ccmAddr);
        } else {
            SynergyUtil.checkoutProject(getLogger(), null, repo.getProjectSpec(), version, repo.getProjectPurpose(), repo.getProjectRelease(), ccmAddr);
            projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
            if (getLogger().isInfoEnabled()) {
                getLogger().info("A new working project [" + projectSpec + "] was created.");
            }
        }
        SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
        waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    File source = new File(waPath, repo.getProjectName());
    if (getLogger().isInfoEnabled()) {
        getLogger().info("We will now copy files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
    }
    // Move files to the expected folder
    try {
        FileUtils.copyDirectoryStructure(source, fileSet.getBasedir());
    } catch (IOException e1) {
        throw new ScmException("Unable to copy directory structure", e1);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("We will list content of checkout directory.");
    }
    // We need to list files in the directory
    List<ScmFile> files = new ArrayList<ScmFile>();
    try {
        @SuppressWarnings("unchecked") List<File> realFiles = FileUtils.getFiles(fileSet.getBasedir(), null, "_ccmwaid.inf");
        for (File f : realFiles) {
            files.add(new ScmFile(f.getPath(), ScmFileStatus.CHECKED_OUT));
        }
    } catch (IOException e) {
        throw new ScmException("Unable to list files in checkout directory", e);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("checkout command end successfully ...");
    }
    return new CheckOutScmResult(files, new ScmResult("multiple commandline", "OK", "OK", true));
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmResult(org.apache.maven.scm.ScmResult) ArrayList(java.util.ArrayList) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 28 with CheckOutScmResult

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

the class SynergyScmProvider method checkout.

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

Example 29 with CheckOutScmResult

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

the class StarteamCheckOutCommand method executeCheckOutCommand.

// ----------------------------------------------------------------------
// AbstractCheckOutCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    if (fileSet.getFileList().size() != 0) {
        throw new ScmException("This provider doesn't support checking out subsets of a directory");
    }
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamCheckOutConsumer consumer = new StarteamCheckOutConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    Commandline cl = createCommandLine(repository, fileSet, version);
    int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        return new CheckOutScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
    }
    return new CheckOutScmResult(cl.toString(), consumer.getCheckedOutFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) StarteamCommandLineUtils(org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Example 30 with CheckOutScmResult

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

the class AccuRevCheckOutCommandTest method testCheckout.

@Test
public void testCheckout() throws Exception {
    when(accurev.mkws("myStream", AccuRevCheckOutCommand.getWorkSpaceName(basedir, "myStream"), basedir)).thenReturn(true);
    List<File> updatedFiles = Collections.singletonList(new File("updated/file"));
    when(accurev.update(basedir, "now")).thenReturn(updatedFiles);
    AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
    CheckOutScmResult result = command.checkout(repo, new ScmFileSet(basedir), new CommandParameters());
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getRelativePathProjectDirectory(), is("/project/dir"));
    List<ScmFile> checkedOutFiles = result.getCheckedOutFiles();
    assertThat(checkedOutFiles.size(), is(1));
    assertHasScmFile(checkedOutFiles, "updated/file", ScmFileStatus.CHECKED_OUT);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) 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)

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