Search in sources :

Example 1 with BranchScmResult

use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.

the class IntegrityScmProvider method branch.

/**
 * Maps to si createdevpath
 */
@Override
protected BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    IntegrityBranchCommand command = new IntegrityBranchCommand();
    command.setLogger(getLogger());
    return (BranchScmResult) command.execute(repository, fileSet, params);
}
Also used : IntegrityBranchCommand(org.apache.maven.scm.provider.integrity.command.branch.IntegrityBranchCommand) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult)

Example 2 with BranchScmResult

use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.

the class HgScmProvider method branch.

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

Example 3 with BranchScmResult

use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.

the class HgBranchCommand method executeBranchCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeBranchCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String branch, ScmBranchParameters scmBranchParameters) throws ScmException {
    if (StringUtils.isBlank(branch)) {
        throw new ScmException("branch must be specified");
    }
    if (!fileSet.getFileList().isEmpty()) {
        throw new ScmException("This provider doesn't support branchging subsets of a directory");
    }
    File workingDir = fileSet.getBasedir();
    // build the command
    String[] branchCmd = new String[] { HgCommandConstants.BRANCH_CMD, branch };
    // keep the command about in string form for reporting
    HgConsumer branchConsumer = new HgConsumer(getLogger()) {

        public void doConsume(ScmFileStatus status, String trimmedLine) {
        // noop
        }
    };
    ScmResult result = HgUtils.execute(branchConsumer, getLogger(), workingDir, branchCmd);
    HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository;
    if (!result.isSuccess()) {
        throw new ScmException("Error while executing command " + joinCmd(branchCmd));
    }
    // First commit.
    String[] commitCmd = new String[] { HgCommandConstants.COMMIT_CMD, HgCommandConstants.MESSAGE_OPTION, scmBranchParameters.getMessage() };
    result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), workingDir, commitCmd);
    if (!result.isSuccess()) {
        throw new ScmException("Error while executing command " + joinCmd(commitCmd));
    }
    if (repository.isPushChanges()) {
        if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) {
            String[] pushCmd = new String[] { HgCommandConstants.PUSH_CMD, HgCommandConstants.NEW_BRANCH_OPTION, repository.getURI() };
            result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), fileSet.getBasedir(), pushCmd);
            if (!result.isSuccess()) {
                throw new ScmException("Error while executing command " + joinCmd(pushCmd));
            }
        }
    }
    // do an inventory to return the files branched (all of them)
    String[] listCmd = new String[] { HgCommandConstants.INVENTORY_CMD };
    HgListConsumer listconsumer = new HgListConsumer(getLogger());
    result = HgUtils.execute(listconsumer, getLogger(), fileSet.getBasedir(), listCmd);
    if (!result.isSuccess()) {
        throw new ScmException("Error while executing command " + joinCmd(listCmd));
    }
    List<ScmFile> files = listconsumer.getFiles();
    List<ScmFile> fileList = new ArrayList<ScmFile>();
    for (ScmFile f : files) {
        fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
    }
    return new BranchScmResult(fileList, result);
}
Also used : ScmException(org.apache.maven.scm.ScmException) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult) ScmResult(org.apache.maven.scm.ScmResult) HgConsumer(org.apache.maven.scm.provider.hg.command.HgConsumer) ArrayList(java.util.ArrayList) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult) ScmFile(org.apache.maven.scm.ScmFile) ScmFileStatus(org.apache.maven.scm.ScmFileStatus) HgListConsumer(org.apache.maven.scm.provider.hg.command.inventory.HgListConsumer) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) HgScmProviderRepository(org.apache.maven.scm.provider.hg.repository.HgScmProviderRepository)

Example 4 with BranchScmResult

use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.

the class CvsExeBranchCommand method executeCvsCommand.

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

Example 5 with BranchScmResult

use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.

the class TfsBranchCommand method executeBranchCommand.

protected ScmResult executeBranchCommand(ScmProviderRepository r, ScmFileSet f, String branch, String message) throws ScmException {
    TfsCommand command = createCommand(r, f, branch);
    StringStreamConsumer out = new StringStreamConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    int status = command.execute(out, err);
    getLogger().info("status of branch command is= " + status + "; err= " + err.getOutput());
    if (status != 0 || err.hasBeenFed()) {
        return new BranchScmResult(command.getCommandString(), "Error code for TFS branch command - " + status, err.getOutput(), false);
    }
    return new BranchScmResult(command.getCommandString(), new ArrayList<ScmFile>(0));
}
Also used : StringStreamConsumer(org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

BranchScmResult (org.apache.maven.scm.command.branch.BranchScmResult)14 ScmException (org.apache.maven.scm.ScmException)8 ArrayList (java.util.ArrayList)4 ScmFile (org.apache.maven.scm.ScmFile)4 File (java.io.File)3 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)3 IOException (java.io.IOException)2 ScmResult (org.apache.maven.scm.ScmResult)2 CvsBranchConsumer (org.apache.maven.scm.provider.cvslib.command.branch.CvsBranchConsumer)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 Commandline (org.codehaus.plexus.util.cli.Commandline)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ScmBranch (org.apache.maven.scm.ScmBranch)1 ScmBranchParameters (org.apache.maven.scm.ScmBranchParameters)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1