use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class MonotoneRepository method getHistoryGet.
@Override
boolean getHistoryGet(OutputStream out, String parent, String basename, String rev) {
File directory = new File(getDirectoryName());
try {
String filename = (new File(parent, basename)).getCanonicalPath().substring(getDirectoryName().length() + 1);
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
String[] argv = { RepoCommand, "cat", "-r", rev, filename };
Executor executor = new Executor(Arrays.asList(argv), directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout());
copyBytes(out::write, executor.getOutputStream());
return true;
} catch (Exception exp) {
LOGGER.log(Level.SEVERE, "Failed to get history: {0}", exp.getClass().toString());
}
return false;
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class MonotoneRepository 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(File file, String sinceRevision) throws IOException {
String filename = getRepoRelativePath(file);
List<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("log");
if (sinceRevision != null) {
cmd.add("--to");
cmd.add(sinceRevision);
}
cmd.add("--no-graph");
cmd.add("--no-merges");
cmd.add("--no-format-dates");
cmd.add(filename);
return new Executor(cmd, new File(getDirectoryName()), sinceRevision != null);
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class MonotoneRepository method determineParent.
@Override
String determineParent(CommandTimeoutType cmdType) throws IOException {
String parent = null;
File directory = new File(getDirectoryName());
List<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("ls");
cmd.add("vars");
cmd.add("database");
Executor executor = new Executor(cmd, directory, RuntimeEnvironment.getInstance().getCommandTimeout(cmdType));
executor.exec();
try (BufferedReader in = new BufferedReader(executor.getOutputReader())) {
String line;
while ((line = in.readLine()) != null) {
if (line.startsWith("database") && line.contains("default-server")) {
String[] parts = line.split("\\s+");
if (parts.length != 3) {
LOGGER.log(Level.WARNING, "Failed to get parent for {0}", getDirectoryName());
}
parent = parts[2];
break;
}
}
}
return parent;
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class AccuRevRepository method annotate.
@Override
public Annotation annotate(File file, String rev) throws IOException {
ArrayList<String> cmd = new ArrayList<>();
// Do not use absolute paths because symbolic links will cause havoc.
String path = getDepotRelativePath(file);
cmd.add(RepoCommand);
cmd.add("annotate");
// version & user
cmd.add("-fvu");
if (rev != null) {
cmd.add("-v");
cmd.add(rev.trim());
}
cmd.add(path);
Executor executor = new Executor(cmd, file.getParentFile(), RuntimeEnvironment.getInstance().getInteractiveCommandTimeout());
AccuRevAnnotationParser parser = new AccuRevAnnotationParser(file.getName());
executor.exec(true, parser);
return parser.getAnnotation();
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class AccuRevRepository method getHistoryLogExecutor.
/**
* Get an executor to be used for retrieving the history log for the given
* file. (used by AccuRevHistoryParser).
*
* @param file file for which history is to be retrieved.
* @return An Executor ready to be started
*/
Executor getHistoryLogExecutor(File file) throws IOException {
// Do not use absolute paths because symbolic links will cause havoc.
String path = getDepotRelativePath(file);
ArrayList<String> cmd = new ArrayList<>();
cmd.add(RepoCommand);
cmd.add("hist");
if (!file.isDirectory()) {
cmd.add("-k");
// get a list of all 'real' file versions
cmd.add("keep");
}
cmd.add(path);
File workingDirectory = file.isDirectory() ? file : file.getParentFile();
return new Executor(cmd, workingDirectory);
}
Aggregations