@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; }
@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<String>(); cmd.add(this.cmd); 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) { OpenGrokLogger.getLogger() .warning( "svn info did not contain an URL for [" + directoryName + "]. Assuming remote repository."); 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) { OpenGrokLogger.getLogger().log(Level.WARNING, "Parser error parsing svn output", saxe); } catch (ParserConfigurationException pce) { OpenGrokLogger.getLogger() .log(Level.WARNING, "Parser configuration error parsing svn output", pce); } catch (IOException ioe) { OpenGrokLogger.getLogger() .log(Level.WARNING, "IOException reading from svn process", ioe); } } else { OpenGrokLogger.getLogger() .warning( "Failed to execute svn info for [" + directoryName + "]. Repository disabled."); } setWorking(rootFound); } }
@Override public InputStream getHistoryGet(String parent, String basename, String rev) { InputStream ret = null; File directory = new File(directoryName); String filename = (new File(parent, basename)).getAbsolutePath().substring(directoryName.length() + 1); List<String> cmd = new ArrayList<String>(); ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK); cmd.add(this.cmd); 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; }