use of org.apache.maven.scm.provider.perforce.command.checkout.PerforceCheckOutCommand 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.provider.perforce.command.checkout.PerforceCheckOutCommand in project maven-scm by apache.
the class PerforceScmProvider method checkout.
protected CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
PerforceCheckOutCommand command = new PerforceCheckOutCommand();
command.setLogger(getLogger());
return (CheckOutScmResult) command.execute(repository, fileSet, params);
}
Aggregations