use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class AccuRevCheckOutCommandTest method testCheckoutToVersionNewWorkspace.
@Test
public void testCheckoutToVersionNewWorkspace() throws Exception {
when(accurev.mkws("anotherStream", AccuRevCheckOutCommand.getWorkSpaceName(basedir, "anotherStream"), basedir)).thenReturn(true);
List<File> updatedFiles = Collections.singletonList(new File("updated/file"));
when(accurev.update(basedir, "now")).thenReturn(updatedFiles);
AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
CommandParameters parameters = new CommandParameters();
parameters.setScmVersion(CommandParameter.SCM_VERSION, new ScmRevision("anotherStream/12"));
CheckOutScmResult result = command.checkout(repo, new ScmFileSet(basedir), parameters);
assertThat(result.isSuccess(), is(true));
assertThat(result.getCheckedOutFiles().size(), is(1));
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class AccuRevCheckOutCommandTest method testReCheckoutExistingWorkspaceDifferentBasis.
@Test
public void testReCheckoutExistingWorkspaceDifferentBasis() throws Exception {
// Set the info result to return a workspace that already exists
info.setWorkSpace("someOldStream_someUser");
info.setBasis("myStream");
info.setTop(basedir.getAbsolutePath());
when(accurev.chws(basedir, "someOldStream_someUser", "mySnapShot")).thenReturn(true);
List<File> emptyPop = Collections.emptyList();
when(accurev.popExternal(basedir, null, null, null)).thenReturn(emptyPop);
List<File> updatedFiles = Collections.singletonList(new File("updated/file"));
when(accurev.update(basedir, null)).thenReturn(updatedFiles);
AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
CommandParameters params = new CommandParameters();
params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot"));
CheckOutScmResult result = command.checkout(repo, new ScmFileSet(basedir), params);
verify(accurev).chws(basedir, "someOldStream_someUser", "mySnapShot");
assertThat(result.isSuccess(), is(true));
assertThat(result.getRelativePathProjectDirectory(), is("/project/dir"));
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class AccuRevCheckOutCommandTest method testCheckoutFailure.
@Test
public void testCheckoutFailure() throws Exception {
when(accurev.mkws("myStream", AccuRevCheckOutCommand.getWorkSpaceName(basedir, "myStream"), basedir)).thenReturn(true);
when(accurev.update(basedir, "now")).thenReturn(null);
AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
CheckOutScmResult result = command.checkout(repo, new ScmFileSet(basedir), new CommandParameters());
assertThat(result.isSuccess(), is(false));
assertThat(result.getProviderMessage(), notNullValue());
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class BazaarCheckOutCommand method executeCheckOutCommand.
/**
* {@inheritDoc}
*/
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
String url = repository.getURI();
File checkoutDir = fileSet.getBasedir();
try {
if (getLogger().isInfoEnabled()) {
getLogger().info("Removing " + checkoutDir);
}
FileUtils.deleteDirectory(checkoutDir);
} catch (IOException e) {
throw new ScmException("Cannot remove " + checkoutDir);
}
// Do the actual checkout
List<String> checkoutCmd = new ArrayList<String>();
checkoutCmd.add(BazaarConstants.BRANCH_CMD);
checkoutCmd.add(url);
checkoutCmd.add(checkoutDir.getAbsolutePath());
if (version != null && StringUtils.isNotEmpty(version.getName())) {
checkoutCmd.add(BazaarConstants.REVISION_OPTION);
checkoutCmd.add("tag:" + version.getName());
}
BazaarConsumer checkoutConsumer = new BazaarConsumer(getLogger());
BazaarUtils.execute(checkoutConsumer, getLogger(), checkoutDir.getParentFile(), (String[]) checkoutCmd.toArray(new String[0]));
// Do inventory to find list of checkedout files
String[] inventoryCmd = new String[] { BazaarConstants.INVENTORY_CMD };
BazaarCheckOutConsumer consumer = new BazaarCheckOutConsumer(getLogger(), checkoutDir);
ScmResult result = BazaarUtils.execute(consumer, getLogger(), checkoutDir, inventoryCmd);
if (!result.isSuccess()) {
throw new ScmException(result.getProviderMessage());
}
return new CheckOutScmResult(consumer.getCheckedOutFiles(), result);
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class AccuRevTagCommandTckTest method testReleasePluginStyleTagThenCheckout.
@SuppressWarnings("deprecation")
@Test
public void testReleasePluginStyleTagThenCheckout() throws Exception {
String tag = "test-tag";
makeFile(getWorkingCopy(), ".acignore", "target/*\ntarget\n");
ScmRepository scmRepository = getScmRepository();
addToWorkingTree(getWorkingCopy(), new File(".acignore"), scmRepository);
CheckInScmResult checkinResult = getScmManager().checkIn(scmRepository, new ScmFileSet(getWorkingCopy()), "add acignore");
assertResultIsSuccess(checkinResult);
TagScmResult tagResult = getScmManager().getProviderByUrl(getScmUrl()).tag(scmRepository, new ScmFileSet(getWorkingCopy()), tag);
assertResultIsSuccess(tagResult);
scmRepository.getProviderRepository().setPersistCheckout(false);
CheckOutScmResult checkoutResult = getScmManager().checkOut(scmRepository, new ScmFileSet(new File(getWorkingCopy(), "target/checkout")), new ScmTag(tag));
assertResultIsSuccess(checkoutResult);
}
Aggregations