use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SCCSget method getRevision.
public static InputStream getRevision(String command, File file, String revision) throws IOException {
InputStream ret = null;
ArrayList<String> argv = new ArrayList<String>();
argv.add(command);
argv.add("get");
argv.add("-p");
if (revision != null) {
argv.add("-r" + revision);
}
argv.add(file.getCanonicalPath());
Executor executor = new Executor(argv);
if (executor.exec() == 0) {
ret = executor.getOutputStream();
}
return ret;
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SSCMRepository method getHistoryLogExecutor.
/**
* Get an executor to be used for retrieving the history log for the named
* file or directory.
*
* @param file The file or directory to retrieve history for
* @param sinceRevision the oldest changeset to return from the executor, or
* {@code null} if all changesets should be returned
* @return An Executor ready to be started
*/
Executor getHistoryLogExecutor(final File file, String sinceRevision) throws IOException {
List<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("history");
if (file.isDirectory()) {
argv.add("/");
} else {
argv.add(file.getName());
}
if (sinceRevision != null && new Scanner(sinceRevision).hasNextInt()) {
argv.add("-v" + (Integer.parseInt(sinceRevision) + 1) + ":" + Integer.MAX_VALUE);
}
argv.add("-w-");
Properties props = getProperties(file);
String branch = props.getProperty(BRANCH_PROPERTY);
if (branch != null && !branch.isEmpty()) {
argv.add("-b" + branch);
}
String repo = props.getProperty(REPOSITORY_PROPERTY);
if (repo != null && !repo.isEmpty()) {
argv.add("-p" + repo);
}
return new Executor(argv, new File(getDirectoryName()), sinceRevision != null);
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SubversionRepository method update.
@Override
public void update() throws IOException {
File directory = new File(getDirectoryName());
List<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("update");
cmd.addAll(getAuthCommandLineParams());
cmd.add("--non-interactive");
Executor executor = new Executor(cmd, directory);
if (executor.exec() != 0) {
throw new IOException(executor.getErrorString());
}
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SubversionRepository method getHistoryLogExecutor.
/**
* Get an executor to be used for retrieving the history log for the named
* file.
*
* @param file The file to retrieve history for
* @param sinceRevision the revision number immediately preceding the first
* revision we want, or {@code null} to fetch the entire
* history
* @return An Executor ready to be started
*/
Executor getHistoryLogExecutor(final File file, String sinceRevision) {
String abs;
try {
abs = file.getCanonicalPath();
} catch (IOException exp) {
LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString());
return null;
}
String filename = "";
if (abs.length() > directoryName.length()) {
filename = abs.substring(directoryName.length() + 1);
}
List<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("log");
cmd.add("--non-interactive");
cmd.addAll(getAuthCommandLineParams());
cmd.add("--xml");
cmd.add("-v");
if (sinceRevision != null) {
cmd.add("-r");
// We would like to use sinceRevision+1 here, but if no new
// revisions have been added after sinceRevision, it would fail
// because there is no such revision as sinceRevision+1. Instead,
// fetch the unneeded revision and remove it later.
cmd.add("BASE:" + sinceRevision);
}
if (filename.length() > 0) {
cmd.add(escapeFileName(filename));
}
return new Executor(cmd, new File(directoryName), sinceRevision != null);
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class RepoRepository method update.
@Override
public void update() throws IOException {
File directory = new File(getDirectoryName());
List<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("sync");
Executor executor = new Executor(cmd, directory);
if (executor.exec() != 0) {
throw new IOException(executor.getErrorString());
}
}
Aggregations