use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class CVSRepository 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");
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 MonotoneRepository method annotate.
/**
* Annotate the specified file/revision.
*
* @param file file to annotate
* @param revision revision to annotate
* @return file annotation
* @throws java.io.IOException
*/
@Override
public 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");
cmd.add(getQuietOption());
if (revision != null) {
cmd.add("-r");
cmd.add(revision);
}
cmd.add(file.getName());
File directory = new File(directoryName);
Executor executor = new Executor(cmd, directory);
if (executor.exec() != 0) {
throw new IOException(executor.getErrorString());
}
Annotation ret;
try (BufferedReader in = new BufferedReader(executor.getOutputReader())) {
ret = new Annotation(file.getName());
String line;
String author = null;
String rev = null;
while ((line = in.readLine()) != null) {
Matcher matcher = ANNOTATION_PATTERN.matcher(line);
if (matcher.find()) {
rev = matcher.group(1);
author = matcher.group(2);
ret.addLine(rev, author, true);
} else {
ret.addLine(rev, author, true);
}
}
}
return ret;
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class MonotoneRepository method update.
@Override
public void update() throws IOException {
File directory = new File(directoryName);
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
List<String> cmd = new ArrayList<>();
cmd.add(RepoCommand);
cmd.add("pull");
cmd.add(getQuietOption());
Executor executor = new Executor(cmd, directory);
if (executor.exec() != 0) {
throw new IOException(executor.getErrorString());
}
cmd.clear();
cmd.add(RepoCommand);
cmd.add("update");
cmd.add(getQuietOption());
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 setDirectoryName.
@Override
public void setDirectoryName(String directoryName) {
super.setDirectoryName(directoryName);
if (isWorking()) {
// set to true if we manage to find the root directory
Boolean rootFound = Boolean.FALSE;
List<String> cmd = new ArrayList<>();
cmd.add(RepoCommand);
cmd.add("info");
cmd.add("--xml");
File directory = new File(getDirectoryName());
Executor executor = new Executor(cmd, directory);
if (executor.exec() == 0) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(executor.getOutputStream());
String url = getValue(document.getElementsByTagName("url").item(0));
if (url == null) {
LOGGER.log(Level.WARNING, "svn info did not contain an URL for [{0}]. Assuming remote repository.", directoryName);
setRemote(true);
} else {
if (!url.startsWith("file")) {
setRemote(true);
}
}
String root = getValue(document.getElementsByTagName("root").item(0));
if (url != null && root != null) {
reposPath = url.substring(root.length());
rootFound = Boolean.TRUE;
}
} catch (SAXException saxe) {
LOGGER.log(Level.WARNING, "Parser error parsing svn output", saxe);
} catch (ParserConfigurationException pce) {
LOGGER.log(Level.WARNING, "Parser configuration error parsing svn output", pce);
} catch (IOException ioe) {
LOGGER.log(Level.WARNING, "IOException reading from svn process", ioe);
}
} else {
LOGGER.log(Level.WARNING, "Failed to execute svn info for [{0}]. Repository disabled.", directoryName);
}
setWorking(rootFound);
}
}
use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.
the class SubversionRepository method getHistoryGet.
@Override
public InputStream getHistoryGet(String parent, String basename, String rev) {
InputStream ret = null;
File directory = new File(directoryName);
String filepath;
try {
filepath = (new File(parent, basename)).getCanonicalPath();
} catch (IOException exp) {
LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString());
return null;
}
String filename = filepath.substring(directoryName.length() + 1);
List<String> cmd = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
cmd.add(RepoCommand);
cmd.add("cat");
cmd.add("-r");
cmd.add(rev);
cmd.add(escapeFileName(filename));
Executor executor = new Executor(cmd, directory);
if (executor.exec() == 0) {
ret = executor.getOutputStream();
}
return ret;
}
Aggregations