Search in sources :

Example 6 with UpdateScmResult

use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.

the class ClearCaseScmProvider method update.

/**
 * {@inheritDoc}
 */
protected UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    ClearCaseUpdateCommand command = new ClearCaseUpdateCommand();
    command.setLogger(getLogger());
    return (UpdateScmResult) command.execute(repository, fileSet, parameters);
}
Also used : UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) ClearCaseUpdateCommand(org.apache.maven.scm.provider.clearcase.command.update.ClearCaseUpdateCommand)

Example 7 with UpdateScmResult

use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.

the class CvsExeUpdateCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected UpdateScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsUpdateConsumer consumer = new CvsUpdateConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new UpdateScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new UpdateScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Also used : CvsUpdateConsumer(org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer) ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 8 with UpdateScmResult

use of org.apache.maven.scm.command.update.UpdateScmResult 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)

Example 9 with UpdateScmResult

use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.

the class UpdateSubprojectsMojo method execute.

/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException {
    super.execute();
    try {
        ScmRepository repository = getScmRepository();
        UpdateScmResult result = getScmManager().update(repository, getFileSet(), getScmVersion(scmVersionType, scmVersion));
        checkResult(result);
        if (result instanceof UpdateScmResultWithRevision) {
            getLog().info("Storing revision in '" + revisionKey + "' project property.");
            if (// Remove the test when we'll use plugin-test-harness 1.0-alpha-2
            project.getProperties() != null) {
                project.getProperties().put(revisionKey, ((UpdateScmResultWithRevision) result).getRevision());
            }
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Cannot run update command : ", e);
    } catch (ScmException e) {
        throw new MojoExecutionException("Cannot run update command : ", e);
    }
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmException(org.apache.maven.scm.ScmException) UpdateScmResultWithRevision(org.apache.maven.scm.command.update.UpdateScmResultWithRevision) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) IOException(java.io.IOException)

Example 10 with UpdateScmResult

use of org.apache.maven.scm.command.update.UpdateScmResult in project maven-scm by apache.

the class TfsScmProvider method update.

protected UpdateScmResult update(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    TfsUpdateCommand command = new TfsUpdateCommand();
    command.setLogger(getLogger());
    return (UpdateScmResult) command.execute(repository, fileSet, parameters);
}
Also used : TfsUpdateCommand(org.apache.maven.scm.provider.tfs.command.TfsUpdateCommand) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult)

Aggregations

UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)35 File (java.io.File)10 ScmFile (org.apache.maven.scm.ScmFile)10 ScmException (org.apache.maven.scm.ScmException)9 UpdateScmResultWithRevision (org.apache.maven.scm.command.update.UpdateScmResultWithRevision)7 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)7 ScmFileSet (org.apache.maven.scm.ScmFileSet)6 ArrayList (java.util.ArrayList)5 ScmRepository (org.apache.maven.scm.repository.ScmRepository)5 Commandline (org.codehaus.plexus.util.cli.Commandline)5 Date (java.util.Date)4 ChangeSet (org.apache.maven.scm.ChangeSet)4 CommandParameters (org.apache.maven.scm.CommandParameters)4 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)4 IOException (java.io.IOException)3 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)3 ScmManager (org.apache.maven.scm.manager.ScmManager)3 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 ScmResult (org.apache.maven.scm.ScmResult)2