use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class PerforceUpdateCommand method executeUpdateCommand.
/**
* {@inheritDoc}
*/
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet files, ScmVersion scmVersion) throws ScmException {
// In Perforce, there is no difference between update and checkout.
// Here we just run the checkout command and map the result onto an
// UpdateScmResult.
PerforceCheckOutCommand command = new PerforceCheckOutCommand();
command.setLogger(getLogger());
CommandParameters params = new CommandParameters();
params.setScmVersion(CommandParameter.SCM_VERSION, scmVersion);
CheckOutScmResult cosr = (CheckOutScmResult) command.execute(repo, files, params);
if (!cosr.isSuccess()) {
return new UpdateScmResult(cosr.getCommandLine(), cosr.getProviderMessage(), cosr.getCommandOutput(), false);
}
PerforceScmProviderRepository p4repo = (PerforceScmProviderRepository) repo;
String clientspec = PerforceScmProvider.getClientspecName(getLogger(), p4repo, files.getBasedir());
Commandline cl = createCommandLine(p4repo, files.getBasedir(), clientspec);
@SuppressWarnings("unused") String location = PerforceScmProvider.getRepoPath(getLogger(), p4repo, files.getBasedir());
PerforceHaveConsumer consumer = new PerforceHaveConsumer(getLogger());
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug(PerforceScmProvider.clean("Executing " + cl.toString()));
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(cl, consumer, err);
if (exitCode != 0) {
String cmdLine = CommandLineUtils.toString(cl.getCommandline());
StringBuilder msg = new StringBuilder("Exit code: " + exitCode + " - " + err.getOutput());
msg.append('\n');
msg.append("Command line was:" + cmdLine);
throw new CommandLineException(msg.toString());
}
} catch (CommandLineException e) {
if (getLogger().isErrorEnabled()) {
getLogger().error("CommandLineException " + e.getMessage(), e);
}
}
return new UpdateScmResultWithRevision(cosr.getCommandLine(), cosr.getCheckedOutFiles(), String.valueOf(consumer.getHave()));
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AbstractScmProvider method blame.
/**
* {@inheritDoc}
*/
public BlameScmResult blame(ScmRepository repository, ScmFileSet fileSet, String filename) throws ScmException {
login(repository, fileSet);
CommandParameters parameters = new CommandParameters();
parameters.setString(CommandParameter.FILE, filename);
return blame(repository.getProviderRepository(), fileSet, parameters);
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AbstractScmProvider method export.
/**
* {@inheritDoc}
*/
public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String outputDirectory) throws ScmException {
login(repository, fileSet);
CommandParameters parameters = new CommandParameters();
parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion);
parameters.setString(CommandParameter.OUTPUT_DIRECTORY, outputDirectory);
return export(repository.getProviderRepository(), fileSet, parameters);
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AbstractScmProvider method update.
private UpdateScmResult update(ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String datePattern, boolean runChangelog) throws ScmException {
login(repository, fileSet);
CommandParameters parameters = new CommandParameters();
parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion);
parameters.setString(CommandParameter.CHANGELOG_DATE_PATTERN, datePattern);
parameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, String.valueOf(runChangelog));
return update(repository.getProviderRepository(), fileSet, parameters);
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AbstractScmProvider method add.
/**
* {@inheritDoc}
*/
public AddScmResult add(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException {
login(repository, fileSet);
CommandParameters parameters = new CommandParameters();
parameters.setString(CommandParameter.MESSAGE, message == null ? "" : message);
// TODO: binary may be dependant on particular files though
// TODO: set boolean?
parameters.setString(CommandParameter.BINARY, "false");
return add(repository.getProviderRepository(), fileSet, parameters);
}
Aggregations