use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.
the class PerforceTagCommandTest method testCommandLine.
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
private void testCommandLine(String tag, String create, String sync) throws Exception {
ScmRepository repository = getScmManager().makeScmRepository("scm:perforce://depot/projects/pathname");
PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
ScmFileSet files = new ScmFileSet(new File("."), Arrays.asList(new File[] { new File("foo.xml"), new File("bar.xml") }));
Commandline cl1 = PerforceTagCommand.createLabelCommandLine(svnRepository, workingDirectory);
assertCommandLine(create, null, cl1);
Commandline cl2 = PerforceTagCommand.createLabelsyncCommandLine(svnRepository, workingDirectory, files, tag);
assertCommandLine(sync, null, cl2);
}
use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.
the class PerforceCheckInCommand method executeCheckInCommand.
/**
* {@inheritDoc}
*/
@Override
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet files, String message, ScmVersion version) throws ScmException {
Commandline cl = createCommandLine((PerforceScmProviderRepository) repo, files.getBasedir());
PerforceCheckInConsumer consumer = new PerforceCheckInConsumer();
try {
String jobs = System.getProperty("maven.scm.jobs");
if (getLogger().isDebugEnabled()) {
getLogger().debug(PerforceScmProvider.clean("Executing " + cl.toString()));
}
PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
String changes = createChangeListSpecification(prepo, files, message, PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir()), jobs);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Sending changelist:\n" + changes);
}
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
int exitCode = CommandLineUtils.executeCommandLine(cl, new ByteArrayInputStream(changes.getBytes()), 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 CheckInScmResult(cl.toString(), consumer.isSuccess() ? "Checkin successful" : "Unable to submit", consumer.getOutput(), consumer.isSuccess());
}
use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.
the class PerforceStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet files) throws ScmException {
PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
actualLocation = PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir());
PerforceStatusConsumer consumer = new PerforceStatusConsumer();
Commandline command = readOpened(prepo, files, consumer);
if (consumer.isSuccess()) {
List<ScmFile> scmfiles = createResults(actualLocation, consumer);
return new StatusScmResult(command.toString(), scmfiles);
}
return new StatusScmResult(command.toString(), "Unable to get status", consumer.getOutput(), consumer.isSuccess());
}
use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.
the class PerforceTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet files, String tag, ScmTagParameters scmTagParameters) throws ScmException {
PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
actualRepoLocation = PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir());
PerforceTagConsumer consumer = new PerforceTagConsumer();
createLabel(repo, files, tag, consumer, false);
if (consumer.isSuccess()) {
syncLabel(repo, files, tag, consumer);
}
if (consumer.isSuccess()) {
// Now update the label if we need to lock it
if (shouldLock()) {
consumer = new PerforceTagConsumer();
createLabel(repo, files, tag, consumer, true);
}
}
if (consumer.isSuccess()) {
// Unclear what to pass as the first arg
return new TagScmResult("p4 label -i", consumer.getTagged());
}
// Unclear what to pass as the first arg
return new TagScmResult("p4 label -i", "Tag failed", consumer.getOutput(), false);
}
use of org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository in project maven-scm by apache.
the class PerforceChangeLogCommandTest method testCommandLineDates.
private void testCommandLineDates(String commandLine, Date date1, Date date2) throws Exception {
ScmRepository repository = getScmManager().makeScmRepository("scm:perforce://depot/projects/pathname");
PerforceScmProviderRepository repo = (PerforceScmProviderRepository) repository.getProviderRepository();
Commandline cl = PerforceChangeLogCommand.createCommandLine(repo, workingDirectory, System.getProperty(PerforceScmProvider.DEFAULT_CLIENTSPEC_PROPERTY), null, date1, date2, null, null);
assertCommandLine(commandLine, null, cl);
}
Aggregations