Search in sources :

Example 31 with CheckOutScmResult

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));
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmRevision(org.apache.maven.scm.ScmRevision) 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) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 32 with CheckOutScmResult

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"));
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) 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) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 33 with CheckOutScmResult

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());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 34 with CheckOutScmResult

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);
}
Also used : ScmException(org.apache.maven.scm.ScmException) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmResult(org.apache.maven.scm.ScmResult) BazaarScmProviderRepository(org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository) ArrayList(java.util.ArrayList) BazaarConsumer(org.apache.maven.scm.provider.bazaar.command.BazaarConsumer) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) IOException(java.io.IOException) File(java.io.File)

Example 35 with CheckOutScmResult

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);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) Test(org.junit.Test) TagCommandTckTest(org.apache.maven.scm.tck.command.tag.TagCommandTckTest)

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