use of org.apache.maven.scm.provider.jazz.command.JazzScmCommand 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);
}
use of org.apache.maven.scm.provider.jazz.command.JazzScmCommand 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;
}
use of org.apache.maven.scm.provider.jazz.command.JazzScmCommand in project maven-scm by apache.
the class JazzCheckOutCommand method createJazzLoadCommand.
public JazzScmCommand createJazzLoadCommand(JazzScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion) {
JazzScmCommand command = new JazzScmCommand(JazzConstants.CMD_LOAD, JazzConstants.ARG_FORCE, repo, fileSet, getLogger());
if (fileSet != null) {
command.addArgument(JazzConstants.ARG_LOCAL_WORKSPACE_PATH);
command.addArgument(fileSet.getBasedir().getAbsolutePath());
}
// This works in tandem with the Tag Command.
// Currently, RTC can not check out directly from a snapshot.
// So, as a work around, the Tag Command creates a workspace name of the same name as the snapshot.
// The functionality here (in using the ScmTag or ScmBranch) assumes that the workspace has been
// created as a part of the Tag Command.
String workspace = repo.getRepositoryWorkspace();
if (scmVersion != null && StringUtils.isNotEmpty(scmVersion.getName())) {
// Just in case we ever do something different for Tags (snapshots) and Branches (streams)
if (scmVersion instanceof ScmTag) {
workspace = scmVersion.getName();
} else if (scmVersion instanceof ScmBranch) {
workspace = scmVersion.getName();
}
}
command.addArgument(workspace);
return command;
}
use of org.apache.maven.scm.provider.jazz.command.JazzScmCommand 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());
}
use of org.apache.maven.scm.provider.jazz.command.JazzScmCommand in project maven-scm by apache.
the class JazzEditCommand method executeEditCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeEditCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing edit command...");
}
DebugLoggerConsumer editConsumer = new DebugLoggerConsumer(getLogger());
ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
JazzScmCommand editCmd = createEditCommand(repo, fileSet);
int status = editCmd.execute(editConsumer, errConsumer);
if (status != 0) {
return new EditScmResult(editCmd.getCommandString(), "Error code for Jazz SCM edit command - " + status, errConsumer.getOutput(), false);
}
return new EditScmResult(editCmd.getCommandString(), "Successfully Completed.", editConsumer.getOutput(), true);
}
Aggregations