use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class AccuRevExportCommandTest method testExportFailure.
@Test
public void testExportFailure() throws Exception {
// info defaults to no workspace...
info.setWorkSpace(null);
when(accurev.info(basedir)).thenReturn(info);
when(accurev.getClientVersion()).thenReturn("4.9.0");
when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("544"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(null);
AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
CommandParameters params = new CommandParameters();
params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/544"));
ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
assertThat(result.isSuccess(), is(false));
assertThat(result.getProviderMessage(), notNullValue());
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class AccuRevExportCommandTest method testNonPersistentWithinExistingWorkspace.
@Test
public void testNonPersistentWithinExistingWorkspace() throws Exception {
// Setup info to return a stream rooted somewhere around here...
info.setWorkSpace("myStream_me");
info.setBasis("someStream");
info.setTop(basedir.getParent());
when(accurev.info(basedir)).thenReturn(info);
when(accurev.stat(basedir)).thenReturn(null);
when(accurev.rmws("myStream_me")).thenReturn(Boolean.TRUE);
List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("now"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
when(accurev.reactivate("myStream_me")).thenReturn(Boolean.TRUE);
repo.setPersistCheckout(true);
AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
CommandParameters params = new CommandParameters();
params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot"));
ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
verify(accurev).rmws("myStream_me");
verify(accurev).reactivate("myStream_me");
assertTrue(result.isSuccess());
// TODO - raise JIRA to move relative path dir to repository rather than checkout result
// dassertThat( result.getRelativePathProjectDirectory(), is( "/project/dir" ) );
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class SvnExeExportCommand method executeExportCommand.
/**
* {@inheritDoc}
*/
protected ExportScmResult executeExportCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, String outputDirectory) throws ScmException {
if (outputDirectory == null) {
outputDirectory = fileSet.getBasedir().getAbsolutePath();
}
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((SvnScmProviderRepository) repo, fileSet.getBasedir(), version, url, outputDirectory);
SvnUpdateConsumer consumer = new SvnUpdateConsumer(getLogger(), fileSet.getBasedir());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (cl.getWorkingDirectory() != null && Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new ExportScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new ExportScmResultWithRevision(cl.toString(), consumer.getUpdatedFiles(), String.valueOf(consumer.getRevision()));
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class IntegrityScmProvider method export.
/**
* Maps to si projectco (no sandbox is used)
*/
@Override
protected ExportScmResult export(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
IntegrityExportCommand command = new IntegrityExportCommand();
command.setLogger(getLogger());
return (ExportScmResult) command.execute(repository, fileSet, params);
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class CvsJavaExportCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected ExportScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsLogListener logListener = new CvsLogListener();
CvsUpdateConsumer consumer = new CvsUpdateConsumer(getLogger());
try {
boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
if (!isSuccess) {
return new ExportScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
String line;
while ((line = stream.readLine()) != null) {
consumer.consumeLine(line);
}
} catch (Exception e) {
e.printStackTrace();
return new ExportScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
return new ExportScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Aggregations