Search in sources :

Example 6 with AccuRev

use of org.apache.maven.scm.provider.accurev.AccuRev 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 7 with AccuRev

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

the class AccuRevAddCommand method executeAccurevCommand.

/**
 * Add.
 *
 * @todo handle the "binary" parameter. AccuRev does a reasonable job of detecting this itself.
 */
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    String message = parameters.getString(CommandParameter.MESSAGE, "");
    File basedir = fileSet.getBasedir();
    List<File> relativeFiles = fileSet.getFileList();
    List<File> addedFiles = accuRev.add(basedir, relativeFiles, message);
    if (addedFiles != null) {
        List<ScmFile> resultFiles = getScmFiles(addedFiles, ScmFileStatus.ADDED);
        return new AddScmResult(accuRev.getCommandLines(), resultFiles);
    } else {
        return new AddScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
    }
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 8 with AccuRev

use of org.apache.maven.scm.provider.accurev.AccuRev 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 9 with AccuRev

use of org.apache.maven.scm.provider.accurev.AccuRev 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 10 with AccuRev

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

the class AccuRevBlameCommand method executeAccurevCommand.

@Override
protected BlameScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    File file = new File(parameters.getString(CommandParameter.FILE));
    List<BlameLine> lines = accuRev.annotate(fileSet.getBasedir(), file);
    if (lines != null) {
        return new BlameScmResult(accuRev.getCommandLines(), lines);
    } else {
        return new BlameScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
    }
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine) AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) File(java.io.File)

Aggregations

AccuRev (org.apache.maven.scm.provider.accurev.AccuRev)11 File (java.io.File)9 AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)6 ScmFile (org.apache.maven.scm.ScmFile)5 AccuRevException (org.apache.maven.scm.provider.accurev.AccuRevException)4 ArrayList (java.util.ArrayList)2 ScmException (org.apache.maven.scm.ScmException)2 ScmVersion (org.apache.maven.scm.ScmVersion)2 AccuRevVersion (org.apache.maven.scm.provider.accurev.AccuRevVersion)2 Date (java.util.Date)1 ScmBranch (org.apache.maven.scm.ScmBranch)1 ScmRevision (org.apache.maven.scm.ScmRevision)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 BlameLine (org.apache.maven.scm.command.blame.BlameLine)1 BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 LoginScmResult (org.apache.maven.scm.command.login.LoginScmResult)1 RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)1