Search in sources :

Example 1 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevTagCommandTest method testAccuRevError.

@Test
public void testAccuRevError() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(new File("/my/workspace/project/dir"));
    final File basedir = testFileSet.getBasedir();
    final String basisStream = "basisStream";
    final AccuRevInfo info = new AccuRevInfo(basedir);
    info.setBasis(basisStream);
    AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
    repo.setStreamName("myStream");
    repo.setAccuRev(accurev);
    repo.setProjectPath("/project/dir");
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.mksnap("theTagName", basisStream)).thenReturn(Boolean.FALSE);
    AccuRevTagCommand command = new AccuRevTagCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.TAG_NAME, "theTagName");
    TagScmResult result = command.tag(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(false));
    assertThat(result.getProviderMessage(), notNullValue());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) AccuRevScmProviderRepository(org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository) CommandParameters(org.apache.maven.scm.CommandParameters) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 2 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevCheckInCommandTest method testCheckInFailure.

@Test
public void testCheckInFailure() throws Exception {
    // Setup test data so that the checkin area is the repo's project path.
    final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
    final File basedir = testFileSet.getBasedir();
    final AccuRevInfo info = new AccuRevInfo(basedir);
    info.setTop(basedir.getAbsolutePath());
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.promoteAll(basedir, "A commit message")).thenReturn(null);
    AccuRevCheckInCommand command = new AccuRevCheckInCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A commit message");
    CheckInScmResult result = command.checkIn(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(false));
    assertThat(result.getProviderMessage(), notNullValue());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 3 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevTckUtil method removeWorkSpace.

public void removeWorkSpace(File basedir) throws Exception {
    try {
        assertLoggedInOK();
    } catch (AssertionError e) {
        return;
    }
    if (basedir.exists()) {
        AccuRevInfo bdInfo = accurevCL.info(basedir);
        if (bdInfo.isWorkSpaceTop()) {
            accurevCL.promoteAll(basedir, "clear default group");
            accurevCL.rmws(bdInfo.getWorkSpace());
        }
    }
}
Also used : AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Example 4 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevCheckOutCommand method extractSource.

@Override
protected List<File> extractSource(AccuRevScmProviderRepository repository, File basedir, AccuRevVersion version) throws AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    AccuRevInfo info = accuRev.info(basedir);
    List<File> extractedFiles = new ArrayList<File>();
    String basisStream = version.getBasisStream();
    String transactionId = version.getTimeSpec();
    boolean success = true;
    if (info.isWorkSpace()) {
        if (!repository.isWorkSpaceTop(info)) {
            throw new AccuRevException(String.format("Can't checkout to %s, " + "a subdirectory of existing workspace %s", basedir, info.getWorkSpace()));
        }
        // workspace exists at this basedir already.
        if (!basisStream.equals(info.getBasis())) {
            // different basis, reparent.
            success = accuRev.chws(basedir, info.getWorkSpace(), basisStream);
        }
        if (success) {
            // repopulate everything in the workspace.
            // note we do NOT want -t here, we just fill in any missing files
            // to the current transaction watermark...
            // the update later on will get the extra files
            List<File> poppedFiles = accuRev.pop(basedir, null);
            if (poppedFiles != null) {
                extractedFiles.addAll(poppedFiles);
            } else {
                success = false;
            }
        }
    } else {
        // not a workspace, make one...
        // TODO set incl rules to only include the projectPath
        // TODO somehow set provider message (via throw exception?
        // if basisStream is null
        String workSpaceName = getWorkSpaceName(basedir, basisStream);
        success = accuRev.mkws(basisStream, workSpaceName, basedir);
        // Even though a new workspace starts with "0" as the high water mark
        // it can't be updated to anything less than its own mkstream transaction
        // now is close enough since even if something does sneak inbetween we
        // were just lucky that it didn't happen before...
        transactionId = "now";
        if (success) {
            getLogger().info("Created workspace " + workSpaceName);
        }
    }
    if (success) {
        List<File> updatedFiles = accuRev.update(basedir, transactionId);
        if (updatedFiles != null) {
            extractedFiles.addAll(updatedFiles);
        } else {
            success = false;
        }
    }
    return success ? extractedFiles : null;
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) AccuRevException(org.apache.maven.scm.provider.accurev.AccuRevException) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Example 5 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class InfoConsumerTest method consume.

private AccuRevInfo consume(String resource) throws IOException {
    AccuRevInfo info = new AccuRevInfo(new File("/my/project/dir"));
    StreamConsumer consumer = new InfoConsumer(info);
    BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream(resource)));
    String line = reader.readLine();
    while (line != null) {
        consumer.consumeLine(line);
        line = reader.readLine();
    }
    return info;
}
Also used : StreamConsumer(org.codehaus.plexus.util.cli.StreamConsumer) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) File(java.io.File) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Aggregations

AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)18 File (java.io.File)10 Test (org.junit.Test)8 AccuRev (org.apache.maven.scm.provider.accurev.AccuRev)6 CommandParameters (org.apache.maven.scm.CommandParameters)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)5 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)5 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)4 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)3 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)3 AccuRevException (org.apache.maven.scm.provider.accurev.AccuRevException)3 ScmFile (org.apache.maven.scm.ScmFile)2 AccuRevScmProviderRepository (org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository)2 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ScmException (org.apache.maven.scm.ScmException)1 ScmVersion (org.apache.maven.scm.ScmVersion)1