use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class BazaarRepository 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("info");
Executor executor = new Executor(cmd, directory);
if (executor.exec() != 0) {
throw new IOException(executor.getErrorString());
}
if (executor.getOutputString().contains("parent branch:")) {
cmd.clear();
cmd.add(RepoCommand);
cmd.add("up");
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 CVSHistoryParser method parse.
/**
* Parse the history for the specified file.
*
* @param file the file to parse history for
* @param repos Pointer to the SubversionReporitory
* @return object representing the file's history
*/
History parse(File file, Repository repos) throws HistoryException {
repository = (CVSRepository) repos;
try {
Executor executor = repository.getHistoryLogExecutor(file);
int status = executor.exec(true, this);
if (status != 0) {
throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status);
}
} catch (IOException e) {
throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e);
}
return history;
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class CVSRepository 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
* @return An Executor ready to be started
*/
Executor getHistoryLogExecutor(final File file) throws IOException {
String abs = file.getCanonicalPath();
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");
if (isBranch == null) {
File tagFile = new File(getDirectoryName(), "CVS/Tag");
if (tagFile.isFile()) {
isBranch = Boolean.TRUE;
try (BufferedReader br = new BufferedReader(new FileReader(tagFile))) {
String line = br.readLine();
if (line != null) {
branch = line.substring(1);
}
} catch (IOException ex) {
LOGGER.log(Level.WARNING, "Failed to work with CVS/Tag file of {0}", getDirectoryName() + ": " + ex.getClass().toString());
} catch (Exception exp) {
LOGGER.log(Level.WARNING, "Failed to get revision tag of {0}", getDirectoryName() + ": " + exp.getClass().toString());
}
} else {
isBranch = Boolean.FALSE;
}
}
if (isBranch.equals(Boolean.TRUE) && branch != null && !branch.isEmpty()) {
// Just generate THIS branch history, we don't care about the other
// branches which are not checked out.
cmd.add("-r" + branch);
} else {
// Get revisions on this branch only (otherwise the revisions
// list produced by the cvs log command would be unsorted).
cmd.add("-b");
}
if (filename.length() > 0) {
cmd.add(filename);
}
return new Executor(cmd, new File(getDirectoryName()));
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class CVSRepository method annotate.
@Override
Annotation annotate(File file, String revision) throws IOException {
ArrayList<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("annotate");
if (revision != null) {
cmd.add("-r");
cmd.add(revision);
}
cmd.add(file.getName());
Executor exec = new Executor(cmd, file.getParentFile());
int status = exec.exec();
if (status != 0) {
LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[] { file.getAbsolutePath(), String.valueOf(status) });
}
return parseAnnotation(exec.getOutputReader(), file.getName());
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class ClearCaseHistoryParser method parse.
History parse(File file, Repository repos) throws HistoryException {
repository = (ClearCaseRepository) repos;
try {
Executor executor = repository.getHistoryLogExecutor(file);
int status = executor.exec(true, this);
if (status != 0) {
throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status);
}
return history;
} catch (IOException e) {
throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e);
}
}
Aggregations