Search in sources :

Example 1 with AccuRevUpdateCommand

use of org.apache.maven.scm.provider.accurev.command.update.AccuRevUpdateCommand in project maven-scm by apache.

the class AccuRevScmProvider method update.

@Override
protected UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    AccuRevScmProviderRepository accurevRepo = (AccuRevScmProviderRepository) repository;
    AccuRevUpdateCommand command = new AccuRevUpdateCommand(getLogger());
    UpdateScmResult result = command.update(repository, fileSet, parameters);
    if (result.isSuccess() && parameters.getBoolean(CommandParameter.RUN_CHANGELOG_WITH_UPDATE)) {
        AccuRevUpdateScmResult accuRevResult = (AccuRevUpdateScmResult) result;
        ScmRevision fromRevision = new ScmRevision(accuRevResult.getFromRevision());
        ScmRevision toRevision = new ScmRevision(accuRevResult.getToRevision());
        parameters.setScmVersion(CommandParameter.START_SCM_VERSION, fromRevision);
        parameters.setScmVersion(CommandParameter.END_SCM_VERSION, toRevision);
        AccuRevVersion startVersion = accurevRepo.getAccuRevVersion(fromRevision);
        AccuRevVersion endVersion = accurevRepo.getAccuRevVersion(toRevision);
        if (startVersion.getBasisStream().equals(endVersion.getBasisStream())) {
            ChangeLogScmResult changeLogResult = changelog(repository, fileSet, parameters);
            if (changeLogResult.isSuccess()) {
                result.setChanges(changeLogResult.getChangeLog().getChangeSets());
            } else {
                getLogger().warn("Changelog from " + fromRevision + " to " + toRevision + " failed");
            }
        } else {
            String comment = "Cross stream update result from " + startVersion + " to " + endVersion;
            String author = "";
            List<ScmFile> files = result.getUpdatedFiles();
            List<ChangeFile> changeFiles = new ArrayList<ChangeFile>(files.size());
            for (ScmFile scmFile : files) {
                changeFiles.add(new ChangeFile(scmFile.getPath()));
            }
            ChangeSet dummyChangeSet = new ChangeSet(new Date(), comment, author, changeFiles);
            // different streams invalidates the change log, insert a dummy change instead.
            List<ChangeSet> changeSets = Collections.singletonList(dummyChangeSet);
            result.setChanges(changeSets);
        }
    }
    return result;
}
Also used : AccuRevUpdateScmResult(org.apache.maven.scm.provider.accurev.command.update.AccuRevUpdateScmResult) ScmRevision(org.apache.maven.scm.ScmRevision) AccuRevUpdateScmResult(org.apache.maven.scm.provider.accurev.command.update.AccuRevUpdateScmResult) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) ArrayList(java.util.ArrayList) Date(java.util.Date) ScmFile(org.apache.maven.scm.ScmFile) AccuRevUpdateCommand(org.apache.maven.scm.provider.accurev.command.update.AccuRevUpdateCommand) ChangeFile(org.apache.maven.scm.ChangeFile) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) ChangeSet(org.apache.maven.scm.ChangeSet)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ChangeFile (org.apache.maven.scm.ChangeFile)1 ChangeSet (org.apache.maven.scm.ChangeSet)1 ScmFile (org.apache.maven.scm.ScmFile)1 ScmRevision (org.apache.maven.scm.ScmRevision)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)1 AccuRevUpdateCommand (org.apache.maven.scm.provider.accurev.command.update.AccuRevUpdateCommand)1 AccuRevUpdateScmResult (org.apache.maven.scm.provider.accurev.command.update.AccuRevUpdateScmResult)1