Search in sources :

Example 1 with BazaarStatusCommand

use of org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand in project maven-scm by apache.

the class BazaarCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
    if (version != null && StringUtils.isNotEmpty(version.getName())) {
        throw new ScmException("This provider can't handle tags.");
    }
    // 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
        BazaarStatusCommand statusCmd = new BazaarStatusCommand();
        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[] { BazaarConstants.COMMIT_CMD, BazaarConstants.MESSAGE_OPTION, message };
    commitCmd = BazaarUtils.expandCommandLine(commitCmd, fileSet);
    ScmResult result = BazaarUtils.execute(new BazaarConsumer(getLogger()), getLogger(), fileSet.getBasedir(), commitCmd);
    // Push to parent branch if any
    BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
    if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath()) && repo.isPushChanges()) {
        String[] pushCmd = new String[] { BazaarConstants.PUSH_CMD, BazaarConstants.NO_STRICT_OPTION, repository.getURI() };
        result = BazaarUtils.execute(new BazaarConsumer(getLogger()), getLogger(), fileSet.getBasedir(), pushCmd);
    }
    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) ArrayList(java.util.ArrayList) BazaarStatusCommand(org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) ScmFile(org.apache.maven.scm.ScmFile) BazaarScmProviderRepository(org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository) BazaarConsumer(org.apache.maven.scm.provider.bazaar.command.BazaarConsumer) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File)

Example 2 with BazaarStatusCommand

use of org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand in project maven-scm by apache.

the class BazaarScmProvider method status.

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

Aggregations

StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)2 BazaarStatusCommand (org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ScmException (org.apache.maven.scm.ScmException)1 ScmFile (org.apache.maven.scm.ScmFile)1 ScmResult (org.apache.maven.scm.ScmResult)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 BazaarConsumer (org.apache.maven.scm.provider.bazaar.command.BazaarConsumer)1 BazaarScmProviderRepository (org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository)1