Search in sources :

Example 6 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class LocalScmProvider method status.

/**
 * {@inheritDoc}
 */
public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    LocalStatusCommand command = new LocalStatusCommand();
    command.setLogger(getLogger());
    return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) LocalStatusCommand(org.apache.maven.scm.provider.local.command.status.LocalStatusCommand)

Example 7 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class IntegrityScmProvider method status.

/**
 * Maps to si viewsandbox with a filter of locally changed files
 */
@Override
protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    IntegrityStatusCommand command = new IntegrityStatusCommand();
    command.setLogger(getLogger());
    return (StatusScmResult) command.execute(repository, fileSet, params);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) IntegrityStatusCommand(org.apache.maven.scm.provider.integrity.command.status.IntegrityStatusCommand)

Example 8 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class HgCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion tag) throws ScmException {
    if (tag != null && !StringUtils.isEmpty(tag.getName())) {
        throw new ScmException("This provider can't handle tags for this operation");
    }
    File workingDir = fileSet.getBasedir();
    String branchName = HgUtils.getCurrentBranchName(getLogger(), workingDir);
    boolean differentOutgoingBranch = repo.isPushChanges() ? HgUtils.differentOutgoingBranchFound(getLogger(), workingDir, branchName) : false;
    // Get files that will be committed (if not specified in fileSet)
    List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
    List<File> files = fileSet.getFileList();
    if (files.isEmpty()) {
        // Either commit all changes
        HgStatusCommand statusCmd = new HgStatusCommand();
        statusCmd.setLogger(getLogger());
        StatusScmResult status = statusCmd.executeStatusCommand(repo, fileSet);
        List<ScmFile> statusFiles = status.getChangedFiles();
        for (ScmFile file : statusFiles) {
            if (file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED || file.getStatus() == ScmFileStatus.MODIFIED) {
                commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
            }
        }
    } else {
        // Or commit spesific files
        for (File file : files) {
            commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
        }
    }
    // Commit to local branch
    String[] commitCmd = new String[] { HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, message };
    commitCmd = HgUtils.expandCommandLine(commitCmd, fileSet);
    ScmResult result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), fileSet.getBasedir(), commitCmd);
    // Push to parent branch if any
    HgScmProviderRepository repository = (HgScmProviderRepository) repo;
    if (repo.isPushChanges()) {
        if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) {
            String[] pushCmd = new String[] { HgCommandConstants.PUSH_CMD, differentOutgoingBranch ? HgCommandConstants.REVISION_OPTION + branchName : null, repository.getURI() };
            result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), fileSet.getBasedir(), pushCmd);
        }
        return new CheckInScmResult(commitedFiles, result);
    }
    return new CheckInScmResult(commitedFiles, result);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) ScmResult(org.apache.maven.scm.ScmResult) StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) HgConsumer(org.apache.maven.scm.provider.hg.command.HgConsumer) ArrayList(java.util.ArrayList) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) ScmFile(org.apache.maven.scm.ScmFile) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) HgStatusCommand(org.apache.maven.scm.provider.hg.command.status.HgStatusCommand) HgScmProviderRepository(org.apache.maven.scm.provider.hg.repository.HgScmProviderRepository)

Example 9 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class ClearCaseStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing status command...");
    }
    Commandline cl = createCommandLine(scmFileSet);
    ClearCaseStatusConsumer consumer = new ClearCaseStatusConsumer(getLogger(), scmFileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getCheckedOutFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 10 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class CvsExeStatusCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsStatusConsumer consumer = new CvsStatusConsumer(getLogger(), cl.getWorkingDirectory());
    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 StatusScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) CvsStatusConsumer(org.apache.maven.scm.provider.cvslib.command.status.CvsStatusConsumer) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Aggregations

StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)40 ScmFile (org.apache.maven.scm.ScmFile)15 ScmException (org.apache.maven.scm.ScmException)14 File (java.io.File)12 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)9 Commandline (org.codehaus.plexus.util.cli.Commandline)9 ArrayList (java.util.ArrayList)6 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)6 ScmResult (org.apache.maven.scm.ScmResult)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)3 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)3 JazzStatusCommand (org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand)3 ScmRepository (org.apache.maven.scm.repository.ScmRepository)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 CommandParameters (org.apache.maven.scm.CommandParameters)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 CategorisedElements (org.apache.maven.scm.provider.accurev.CategorisedElements)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 BazaarStatusCommand (org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand)2