use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class PerforceRepository method getHistoryGet.
@Override
InputStream getHistoryGet(String parent, String basename, String rev) {
ArrayList<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("print");
cmd.add("-q");
cmd.add(basename + getRevisionCmd(rev));
Executor executor = new Executor(cmd, new File(parent));
executor.exec();
return new ByteArrayInputStream(executor.getOutputString().getBytes());
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class PerforceRepository method isInP4Depot.
/**
* Check if a given file is in the depot
*
* @param file The file to test
* @return true if the given file is in the depot, false otherwise
*/
public static boolean isInP4Depot(File file) {
boolean status = false;
if (testRepo.isWorking()) {
ArrayList<String> cmd = new ArrayList<>();
String name = file.getName();
File dir = file.getParentFile();
if (file.isDirectory()) {
dir = file;
name = "*";
cmd.add(testRepo.RepoCommand);
cmd.add("dirs");
cmd.add(name);
Executor executor = new Executor(cmd, dir);
executor.exec();
/* OUTPUT:
stdout: //depot_path/name
stderr: name - no such file(s).
*/
status = (executor.getOutputString().contains("//"));
}
if (!status) {
cmd.clear();
cmd.add(testRepo.RepoCommand);
cmd.add("files");
cmd.add(name);
Executor executor = new Executor(cmd, dir);
executor.exec();
/* OUTPUT:
stdout: //depot_path/name
stderr: name - no such file(s).
*/
status = (executor.getOutputString().contains("//"));
}
}
return status;
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SSCMHistoryParser method parse.
History parse(File file, String sinceRevision) throws HistoryException {
try {
Executor executor = repository.getHistoryLogExecutor(file, sinceRevision);
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 SSCMRepository method annotate.
/**
* Annotate the specified file/revision.
*
* @param file file to annotate
* @param revision revision to annotate
* @return file annotation
*/
@Override
Annotation annotate(File file, String revision) throws IOException {
ArrayList<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("annotate");
argv.add(file.getName());
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);
}
if (revision != null) {
argv.add("-aV:" + revision);
}
Executor exec = new Executor(argv, file.getParentFile());
int status = exec.exec();
if (status != 0) {
LOGGER.log(Level.WARNING, "Failed annotate for: {2} \"{0}\" Exit code: {1}", new Object[] { file.getAbsolutePath(), String.valueOf(status), revision });
}
return parseAnnotation(exec.getOutputReader(), file.getName());
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SSCMRepository method update.
@Override
void update() throws IOException {
File directory = new File(getDirectoryName());
List<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("get");
argv.add("/");
Properties props = getProperties(directory);
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);
}
argv.add("-r");
argv.add("-q");
argv.add("-tmodify");
argv.add("-wreplace");
Executor executor = new Executor(argv, directory);
if (executor.exec() != 0) {
throw new IOException(executor.getErrorString());
}
}
Aggregations