use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class BitKeeperRepository method annotate.
/**
* Annotate the specified file/revision. The options {@code -aur} to @{code bk annotate} specify that Bitkeeper will output the
* last user to edit the line, the last revision the line was edited, and then the line itself, each separated by a
* hard tab.
*
* @param file file to annotate
* @param revision revision to annotate, or null for latest
* @return annotation file annotation
*/
@Override
public Annotation annotate(File file, String revision) throws IOException {
final File absolute = file.getCanonicalFile();
final File directory = absolute.getParentFile();
final String basename = absolute.getName();
final ArrayList<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("annotate");
argv.add("-aur");
if (revision != null) {
argv.add("-r" + revision);
}
argv.add(basename);
final Executor executor = new Executor(argv, directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout());
final BitKeeperAnnotationParser parser = new BitKeeperAnnotationParser(basename);
int status = executor.exec(true, parser);
if (status != 0) {
LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[] { file.getAbsolutePath(), String.valueOf(status) });
throw new IOException(executor.getErrorString());
} else {
return parser.getAnnotation();
}
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class BitKeeperRepository method getHistory.
/**
* Construct a History for a file in this repository.
*
* @param file a file in the repository
* @param sinceRevision omit history from before, and including, this revision
* @return history a history object
*/
@Override
History getHistory(File file, String sinceRevision) throws HistoryException {
final File absolute = file.getAbsoluteFile();
final File directory = absolute.getParentFile();
final String basename = absolute.getName();
final ArrayList<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("log");
if (sinceRevision != null) {
argv.add("-r" + sinceRevision + "..");
}
argv.add("-d" + LOG_DSPEC);
argv.add(basename);
final Executor executor = new Executor(argv, directory);
final BitKeeperHistoryParser parser = new BitKeeperHistoryParser(datePatterns[0]);
if (executor.exec(true, parser) != 0) {
throw new HistoryException(executor.getErrorString());
}
final RuntimeEnvironment env = RuntimeEnvironment.getInstance();
final History history = parser.getHistory();
// because we know it :-)
if (env.isTagsEnabled()) {
assignTagsInHistory(history);
}
return history;
}
use of org.opengrok.indexer.util.Executor in project OpenGrok by OpenGrok.
the class BitKeeperRepository method buildTagList.
/**
* Constructs a set of tags up front.
*
* @param directory the repository directory
* @param cmdType command timeout type
*/
@Override
public void buildTagList(File directory, CommandTimeoutType cmdType) {
final ArrayList<String> argv = new ArrayList<>();
argv.add("bk");
argv.add("tags");
argv.add("-d" + getTagDspec());
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
final Executor executor = new Executor(argv, directory, env.getCommandTimeout(cmdType));
final BitKeeperTagParser parser = new BitKeeperTagParser(datePatterns[0]);
int status = executor.exec(true, parser);
if (status != 0) {
LOGGER.log(Level.WARNING, "Failed to get tags for: \"{0}\" Exit code: {1}", new Object[] { directory.getAbsolutePath(), String.valueOf(status) });
} else {
tagList = parser.getEntries();
}
}
Aggregations