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