Search in sources :

Example 11 with AccuRevInfo

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

the class AccuRevCheckInCommand method executeAccurevCommand.

@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    String message = parameters.getString(CommandParameter.MESSAGE);
    List<File> promotedFiles = null;
    File basedir = fileSet.getBasedir();
    List<File> fileList = fileSet.getFileList();
    if (fileList.isEmpty()) {
        // TODO the above test will be matched by a fileset where excludes and includes produce a set with no files.
        // This is
        // NOT the same as a fileset created with only a base directory. Raise maven-scm JIRA for this.
        AccuRevInfo info = accuRev.info(basedir);
        if (repository.isWorkSpaceRoot(info)) {
            promotedFiles = accuRev.promoteAll(basedir, message);
        } else {
            throw new ScmException(String.format("Unsupported recursive checkin for %s. Not the workspace root", basedir.getAbsolutePath()));
        }
    } else {
        promotedFiles = accuRev.promote(basedir, fileList, message);
    }
    if (promotedFiles != null) {
        Iterator<File> iter = promotedFiles.iterator();
        while (iter.hasNext()) {
            if (new File(basedir, iter.next().getPath()).isDirectory()) {
                iter.remove();
            }
        }
        // TODO capture the transaction id from the promote
        return new CheckInScmResult(accuRev.getCommandLines(), getScmFiles(promotedFiles, ScmFileStatus.CHECKED_IN));
    } else {
        return new CheckInScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
    }
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) ScmException(org.apache.maven.scm.ScmException) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Example 12 with AccuRevInfo

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

the class AccuRevLoginCommand method executeAccurevCommand.

@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    boolean result = false;
    AccuRev accurev = repository.getAccuRev();
    AccuRevInfo info = accurev.info(null);
    String providerMessage = "";
    if (info == null) {
        providerMessage = "Unable to retrieve accurev info";
    } else if (repository.getUser() != null) {
        // Check if we've already logged in as this user
        result = repository.getUser().equals(info.getUser());
        if (result) {
            providerMessage = "Skipping login - already logged in as " + repository.getUser();
        } else {
            result = accurev.login(repository.getUser(), repository.getPassword());
            providerMessage = (result ? "Success" : "Failure") + " logging in as " + repository.getUser();
        }
    } else {
        result = info.isLoggedIn();
        providerMessage = result ? ("Logged in externally as " + info.getUser()) : "Not logged in";
    }
    getLogger().debug(providerMessage);
    return new LoginScmResult(accurev.getCommandLines(), providerMessage, accurev.getErrorOutput(), result);
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Example 13 with AccuRevInfo

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

the class AccuRevUpdateCommand method executeAccurevCommand.

@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    File basedir = fileSet.getBasedir();
    AccuRevInfo info = accuRev.info(basedir);
    if (!info.isWorkSpace()) {
        throw new AccuRevException("No workspace at " + basedir.getAbsolutePath());
    }
    String startRevision = getStartRevision(repository, parameters, info);
    ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null);
    String updateTransactionId = null;
    if (scmVersion != null) {
        AccuRevVersion updateVersion = repository.getAccuRevVersion(scmVersion);
        // Reparent if necessary
        String newBasisStream = updateVersion.getBasisStream();
        if (newBasisStream != null && (!(newBasisStream.equals(info.getWorkSpace()) || newBasisStream.equals(info.getBasis())))) {
            getLogger().info("Reparenting " + info.getWorkSpace() + " to " + newBasisStream);
            accuRev.chws(basedir, info.getWorkSpace(), newBasisStream);
        }
        if (!updateVersion.isNow()) {
            updateTransactionId = updateVersion.getTimeSpec();
        }
    }
    if (updateTransactionId == null) {
        updateTransactionId = repository.getDepotTransactionId(info.getWorkSpace(), "now");
    }
    String endRevision = repository.getRevision(info.getWorkSpace(), updateTransactionId);
    List<File> updatedFiles = accuRev.update(basedir, updateTransactionId);
    if (updatedFiles != null) {
        return new AccuRevUpdateScmResult(accuRev.getCommandLines(), getScmFiles(updatedFiles, ScmFileStatus.UPDATED), startRevision, endRevision);
    } else {
        return new AccuRevUpdateScmResult(accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), null, null, false);
    }
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) AccuRevException(org.apache.maven.scm.provider.accurev.AccuRevException) AccuRevVersion(org.apache.maven.scm.provider.accurev.AccuRevVersion) File(java.io.File) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) ScmVersion(org.apache.maven.scm.ScmVersion)

Example 14 with AccuRevInfo

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

the class AccuRevCommandLine method info.

public AccuRevInfo info(File basedir) throws AccuRevException {
    setWorkingDirectory(basedir);
    String[] info = { "info" };
    AccuRevInfo result = new AccuRevInfo(basedir);
    executeCommandLine(info, null, new InfoConsumer(result));
    return result;
}
Also used : AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Example 15 with AccuRevInfo

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

the class InfoConsumerTest method testConsumeOutsideWorkspace.

@Test
public void testConsumeOutsideWorkspace() throws Exception {
    AccuRevInfo info = consume("/info.outsideworkspace.txt");
    assertNull(info.getBasis());
    assertNull(info.getTop());
    assertNull(info.getWorkSpace());
    assertThat(info.getUser(), is("ggardner"));
    assertThat(info.isLoggedIn(), is(true));
}
Also used : AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test)

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