Search in sources :

Example 11 with JazzScmProviderRepository

use of org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository in project maven-scm by apache.

the class JazzCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion scmVersion) throws ScmException {
    if (scmVersion != null && StringUtils.isNotEmpty(scmVersion.getName())) {
        throw new ScmException("This provider command can't handle tags.");
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing checkin command...");
    }
    // Create a changeset. We need to do this, as otherwise the information contained in the message
    // will be lost forever.
    JazzScmCommand createChangesetCmd = createCreateChangesetCommand(repository, fileSet, message);
    DebugLoggerConsumer outputConsumer = new DebugLoggerConsumer(getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    int status = createChangesetCmd.execute(outputConsumer, errConsumer);
    if (status != 0) {
        return new CheckInScmResult(createChangesetCmd.getCommandString(), "Error code for Jazz SCM create changeset command - " + status, errConsumer.getOutput(), false);
    }
    // As we just created a change set, we now need to call the status command so we can parse the
    // newly created change set.
    JazzStatusCommand statusCommand = new JazzStatusCommand();
    statusCommand.setLogger(getLogger());
    statusCommand.executeStatusCommand(repository, fileSet);
    // NOTE: For isPushChangesAndHaveFlowTargets() to work, a scm status call must have been called first!!!
    // As the Workspace name and alias, and the Flow Target name and alias are needed.
    // Check to see if we've got a flow target and had a workItem defined (via -DworkItem=XXXX)
    JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repository;
    if (jazzRepo.isPushChangesAndHaveFlowTargets() && StringUtils.isNotEmpty(jazzRepo.getWorkItem())) {
        List<Integer> changeSetAliases = jazzRepo.getOutgoingChangeSetAliases();
        if (changeSetAliases != null && !changeSetAliases.isEmpty()) {
            for (Integer changeSetAlias : changeSetAliases) {
                // Associate a work item if we need too.
                JazzScmCommand changesetAssociateCmd = createChangesetAssociateCommand(repository, changeSetAlias);
                outputConsumer = new DebugLoggerConsumer(getLogger());
                errConsumer = new ErrorConsumer(getLogger());
                status = changesetAssociateCmd.execute(outputConsumer, errConsumer);
                if (status != 0) {
                    return new CheckInScmResult(changesetAssociateCmd.getCommandString(), "Error code for Jazz SCM changeset associate command - " + status, errConsumer.getOutput(), false);
                }
            }
        }
    }
    // Now check in the files themselves.
    return executeCheckInCommand(repository, fileSet, scmVersion);
}
Also used : ScmException(org.apache.maven.scm.ScmException) JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) DebugLoggerConsumer(org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Example 12 with JazzScmProviderRepository

use of org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository in project maven-scm by apache.

the class JazzCheckInCommand method createChangesetAssociateCommand.

public JazzScmCommand createChangesetAssociateCommand(ScmProviderRepository repo, Integer changeSetAlias) {
    JazzScmCommand command = new JazzScmCommand(JazzConstants.CMD_CHANGESET, JazzConstants.CMD_SUB_ASSOCIATE, repo, false, null, getLogger());
    // Add the change set alias
    JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
    // SCM-812 - Jazz SCM Alias Id's roll over to zero, not 1000 as advertised.
    // So, we need to add the changeSetAlias with leading zeros.
    command.addArgument(StringUtils.leftPad(changeSetAlias.toString(), 4, "0"));
    // Add the work item number
    command.addArgument(jazzRepo.getWorkItem());
    return command;
}
Also used : JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Example 13 with JazzScmProviderRepository

use of org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository in project maven-scm by apache.

the class JazzCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion, boolean recursive, boolean shallow) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing checkout command...");
    }
    JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
    JazzScmCommand checkoutCmd = createJazzLoadCommand(jazzRepo, fileSet, scmVersion);
    JazzCheckOutConsumer checkoutConsumer = new JazzCheckOutConsumer(repo, getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    int status = checkoutCmd.execute(checkoutConsumer, errConsumer);
    if (status != 0) {
        return new CheckOutScmResult(checkoutCmd.getCommandString(), "Error code for Jazz SCM checkout (load) command - " + status, errConsumer.getOutput(), false);
    }
    return new CheckOutScmResult(checkoutCmd.getCommandString(), checkoutConsumer.getCheckedOutFiles());
}
Also used : ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Example 14 with JazzScmProviderRepository

use of org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository in project maven-scm by apache.

the class JazzListCommand method executeListCommand.

/**
 * {@inheritDoc}
 */
protected ListScmResult executeListCommand(ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing list command...");
    }
    JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
    JazzListConsumer listConsumer = new JazzListConsumer(repo, getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    JazzScmCommand listCmd = createListCommand(jazzRepo, fileSet, recursive, version);
    int status = listCmd.execute(listConsumer, errConsumer);
    if (status != 0) {
        return new ListScmResult(listCmd.getCommandString(), "Error code for Jazz SCM list command - " + status, errConsumer.getOutput(), false);
    }
    return new ListScmResult(listCmd.getCommandString(), listConsumer.getFiles());
}
Also used : ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Example 15 with JazzScmProviderRepository

use of org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository in project maven-scm by apache.

the class JazzStatusConsumer method extractComponent.

private void extractComponent(String line) {
    // With no stream (flow target):
    // Component: (1001) "BogusComponent"
    // With a stream:
    // Component: (1158) "GPDB" <-> (1157) "GPDBStream"
    // With some additional information:
    // Component: (1002) "FireDragon" <-> (1005) "MavenR3Stream Workspace" (outgoing addition)
    Matcher matcher = COMPONENT_PATTERN1.matcher(line);
    if (matcher.find()) {
        // Component: (1001) "BogusComponent"
        JazzScmProviderRepository jazzRepository = (JazzScmProviderRepository) getRepository();
        int componentAlias = Integer.parseInt(matcher.group(1));
        String component = matcher.group(2);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Successfully parsed \"Component:\" line:");
            getLogger().debug("  componentAlias = " + componentAlias);
            getLogger().debug("  component      = " + component);
        }
        jazzRepository.setComponent(component);
    }
    matcher = COMPONENT_PATTERN2.matcher(line);
    if (matcher.find()) {
        // Component: (1158) "GPDB" <-> (1157) "GPDBStream"
        JazzScmProviderRepository jazzRepository = (JazzScmProviderRepository) getRepository();
        int componentAlias = Integer.parseInt(matcher.group(1));
        String component = matcher.group(2);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Successfully parsed \"Component:\" line:");
            getLogger().debug("  componentAlias = " + componentAlias);
            getLogger().debug("  component      = " + component);
        }
        jazzRepository.setComponent(component);
    }
}
Also used : Matcher(java.util.regex.Matcher) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Aggregations

JazzScmProviderRepository (org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)17 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)7 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)6 DebugLoggerConsumer (org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer)4 Commandline (org.codehaus.plexus.util.cli.Commandline)4 Matcher (java.util.regex.Matcher)3 StreamConsumer (org.codehaus.plexus.util.cli.StreamConsumer)3 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 File (java.io.File)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 ScmException (org.apache.maven.scm.ScmException)1 ScmFile (org.apache.maven.scm.ScmFile)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 ScmResult (org.apache.maven.scm.ScmResult)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 ListScmResult (org.apache.maven.scm.command.list.ListScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 JazzAddCommand (org.apache.maven.scm.provider.jazz.command.add.JazzAddCommand)1