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);
}
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));
}
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);
}
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());
}
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);
}
Aggregations