use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnExeBranchCommandTckTest method testCommandLine.
private void testCommandLine(String scmUrl, String branch, File messageFile, String user, String commandLine, ScmBranchParameters scmBranchParameters) throws Exception {
File workingDirectory = getTestFile("target/svn-update-command-test");
ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
svnRepository.setUser(user);
Commandline cl = null;
if (scmBranchParameters == null) {
cl = SvnBranchCommand.createCommandLine(svnRepository, workingDirectory, branch, messageFile);
} else {
cl = SvnBranchCommand.createCommandLine(svnRepository, workingDirectory, branch, messageFile, scmBranchParameters);
}
assertCommandLine(commandLine, workingDirectory, cl);
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnCheckInCommand method executeCheckInCommand.
/**
* {@inheritDoc}
*/
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
if (version != null && StringUtils.isNotEmpty(version.getName())) {
throw new ScmException("This provider command can't handle tags.");
}
File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null);
try {
FileUtils.fileWrite(messageFile.getAbsolutePath(), message);
} catch (IOException ex) {
return new CheckInScmResult(null, "Error while making a temporary file for the commit message: " + ex.getMessage(), null, false);
}
Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet, messageFile);
SvnCheckInConsumer consumer = new SvnCheckInConsumer(getLogger(), fileSet.getBasedir());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
} finally {
try {
FileUtils.forceDelete(messageFile);
} catch (IOException ex) {
// ignore
}
}
if (exitCode != 0) {
return new CheckInScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new CheckInScmResult(cl.toString(), consumer.getCheckedInFiles(), Integer.toString(consumer.getRevision()));
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
// TODO: could do this with propset?
if (binary) {
throw new ScmException("This provider does not yet support binary files");
}
if (fileSet.getFileList().isEmpty()) {
throw new ScmException("You must provide at least one file/directory to add");
}
Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList());
SvnAddConsumer consumer = new SvnAddConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new AddScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new AddScmResult(cl.toString(), consumer.getAddedFiles());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnBlameCommand method executeBlameCommand.
/**
* {@inheritDoc}
*/
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
Commandline cl = createCommandLine((SvnScmProviderRepository) repo, workingDirectory.getBasedir(), filename);
SvnBlameConsumer consumer = new SvnBlameConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new BlameScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new BlameScmResult(cl.toString(), consumer.getLines());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnBlameCommand method createCommandLine.
public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, String filename) {
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
cl.createArg().setValue("blame");
cl.createArg().setValue("--xml");
cl.createArg().setValue(filename);
return cl;
}
Aggregations