use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class ClearCaseAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet, String string, boolean b) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing add command...");
}
Commandline cl = createCommandLine(scmFileSet);
ClearCaseAddConsumer consumer = new ClearCaseAddConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
// First we need to 'check out' the current directory
Commandline checkoutCurrentDirCommandLine = ClearCaseEditCommand.createCheckoutCurrentDirCommandLine(scmFileSet);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + checkoutCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkoutCurrentDirCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(checkoutCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
if (exitCode == 0) {
// Then we add the file
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
}
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
if (exitCode == 0) {
// Then we check in the current directory again.
Commandline checkinCurrentDirCommandLine = ClearCaseEditCommand.createCheckinCurrentDirCommandLine(scmFileSet);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + checkinCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkinCurrentDirCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(checkinCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), 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.getAddedFiles());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class HgStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
public StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
File workingDir = fileSet.getBasedir();
HgStatusConsumer consumer = new HgStatusConsumer(getLogger(), workingDir);
String[] statusCmd = new String[] { HgCommandConstants.STATUS_CMD };
ScmResult result = HgUtils.execute(consumer, getLogger(), workingDir, statusCmd);
return new StatusScmResult(consumer.getStatus(), result);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class CvsJavaStatusCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected StatusScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsLogListener logListener = new CvsLogListener();
CvsStatusConsumer consumer = new CvsStatusConsumer(getLogger(), cl.getWorkingDirectory());
try {
boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
if (!isSuccess) {
return new StatusScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
String line;
while ((line = stream.readLine()) != null) {
consumer.consumeLine(line);
}
} catch (Exception e) {
e.printStackTrace();
return new StatusScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class JazzStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
public StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing status command...");
}
JazzStatusConsumer statusConsumer = new JazzStatusConsumer(repo, getLogger());
ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
JazzScmCommand statusCmd = createStatusCommand(repo, fileSet);
int status = statusCmd.execute(statusConsumer, errConsumer);
if (status != 0) {
return new StatusScmResult(statusCmd.getCommandString(), "Error code for Jazz SCM status command - " + status, errConsumer.getOutput(), false);
}
if (getLogger().isDebugEnabled()) {
if (!statusConsumer.getChangedFiles().isEmpty()) {
getLogger().debug("Iterating over \"Status\" results");
for (ScmFile file : statusConsumer.getChangedFiles()) {
getLogger().debug(file.getPath() + " : " + file.getStatus());
}
} else {
getLogger().debug("There are no differences");
}
}
return new StatusScmResult(statusCmd.getCommandString(), statusConsumer.getChangedFiles());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class StarteamScmProvider method status.
/**
* {@inheritDoc}
*/
public StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
fileSet = fixUpScmFileSetAbsoluteFilePath(fileSet);
StarteamStatusCommand command = new StarteamStatusCommand();
command.setLogger(getLogger());
return (StatusScmResult) command.execute(repository, fileSet, parameters);
}
Aggregations