use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnChangeLogCommandTest method testCommandLine.
private void testCommandLine(String scmUrl, ScmVersion startVersion, ScmVersion endVersion, String commandLine) throws Exception {
File workingDirectory = getTestFile("target/svn-update-command-test");
ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
Commandline cl = SvnChangeLogCommand.createCommandLine(svnRepository, workingDirectory, null, null, null, startVersion, endVersion);
assertCommandLine(commandLine, workingDirectory, cl);
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnExportCommandTest method testCommandLine.
private void testCommandLine(String scmUrl, File workingDirectory, File exportDirectory, String commandLine) throws Exception {
ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
Commandline cl = SvnExeExportCommand.createCommandLine(svnRepository, exportDirectory, null, scmUrl, exportDirectory != null ? exportDirectory.getAbsolutePath() : null);
assertCommandLine(commandLine, exportDirectory, cl);
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class PerforceCheckInCommand method createCommandLine.
public static Commandline createCommandLine(PerforceScmProviderRepository repo, File workingDirectory) {
Commandline command = PerforceScmProvider.createP4Command(repo, workingDirectory);
command.createArg().setValue("submit");
command.createArg().setValue("-i");
return command;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class PerforceCheckOutCommand method getLastChangelist.
private int getLastChangelist(PerforceScmProviderRepository repo, File workingDirectory, String specname) {
int lastChangelist = 0;
try {
Commandline command = PerforceScmProvider.createP4Command(repo, workingDirectory);
command.createArg().setValue("-c" + specname);
command.createArg().setValue("changes");
command.createArg().setValue("-m1");
command.createArg().setValue("-ssubmitted");
command.createArg().setValue("//" + specname + "/...");
getLogger().debug("Executing: " + PerforceScmProvider.clean(command.toString()));
Process proc = command.execute();
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
String lastChangelistStr = "";
while ((line = br.readLine()) != null) {
getLogger().debug("Consuming: " + line);
Pattern changeRegexp = Pattern.compile("Change (\\d+)");
Matcher matcher = changeRegexp.matcher(line);
if (matcher.find()) {
lastChangelistStr = matcher.group(1);
}
}
br.close();
try {
lastChangelist = Integer.parseInt(lastChangelistStr);
} catch (NumberFormatException nfe) {
getLogger().debug("Could not parse changelist from line " + line);
}
} catch (IOException e) {
getLogger().error(e);
} catch (CommandLineException e) {
getLogger().error(e);
}
return lastChangelist;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class PerforceCheckOutCommand method createCommandLine.
public static Commandline createCommandLine(PerforceScmProviderRepository repo, File workingDirectory, ScmVersion version, String specname) {
Commandline command = PerforceScmProvider.createP4Command(repo, workingDirectory);
command.createArg().setValue("-c" + specname);
command.createArg().setValue("sync");
// Use a simple heuristic to determine if we should use the Force flag
// on sync. Forcing sync is a HUGE performance hit but is required in
// rare instances where source is somehow deleted. If the target
// directory is completely empty, assume a force is required. If
// not empty, we assume a previous checkout was already done and a normal
// sync will suffice.
// SCM-110
String[] files = workingDirectory.list();
if (files == null || files.length == 0) {
// We need to force so checkout to an empty directory will work.
command.createArg().setValue("-f");
}
// latter until the exact semantics are clearer.
if (version != null && StringUtils.isNotEmpty(version.getName())) {
command.createArg().setValue("@" + version.getName());
}
return command;
}
Aggregations