@Test public void testGetHistoryGet() throws Exception { setUpTestRepository(); File root = new File(repository.getSourceRoot(), "mercurial"); MercurialRepository mr = (MercurialRepository) RepositoryFactory.getRepository(root); String exp_str = "This will be a first novel of mine.\n" + "\n" + "Chapter 1.\n" + "\n" + "Let's write some words. It began like this:\n" + "\n" + "...\n"; byte[] buffer = new byte[1024]; InputStream input = mr.getHistoryGet(root.getCanonicalPath(), "novel.txt", REVISIONS[0]); assertNotNull(input); String str = ""; int len; while ((len = input.read(buffer)) > 0) { str += new String(buffer, 0, len); } assertNotSame(str.length(), 0); assertEquals(exp_str, str); }
@Override boolean getHistoryGet( BufferSink sink, String parent, String basename, String rev) { String fullpath; try { fullpath = new File(parent, basename).getCanonicalPath(); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString()); return false; } HistoryRevResult result = getHistoryRev(sink::write, fullpath, rev); if (!result.success && result.iterations < 1) { String origpath; try { origpath = findOriginalName(fullpath, rev); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get original revision: {0}", exp.getClass().toString()); return false; } if (origpath != null && !origpath.equals(fullpath)) { result = getHistoryRev(sink, origpath, rev); } } return result.success; }
MercurialRepository extends Repository { @Override boolean getHistoryGet( BufferSink sink, String parent, String basename, String rev) { String fullpath; try { fullpath = new File(parent, basename).getCanonicalPath(); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString()); return false; } HistoryRevResult result = getHistoryRev(sink::write, fullpath, rev); if (!result.success && result.iterations < 1) { String origpath; try { origpath = findOriginalName(fullpath, rev); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get original revision: {0}", exp.getClass().toString()); return false; } if (origpath != null && !origpath.equals(fullpath)) { result = getHistoryRev(sink, origpath, rev); } } return result.success; } }
MercurialRepository extends Repository { @Override boolean getHistoryGet( BufferSink sink, String parent, String basename, String rev) { String fullpath; try { fullpath = new File(parent, basename).getCanonicalPath(); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString()); return false; } HistoryRevResult result = getHistoryRev(sink::write, fullpath, rev); if (!result.success && result.iterations < 1) { String origpath; try { origpath = findOriginalName(fullpath, rev); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get original revision: {0}", exp.getClass().toString()); return false; } if (origpath != null && !origpath.equals(fullpath)) { result = getHistoryRev(sink, origpath, rev); } } return result.success; } MercurialRepository(); }
MercurialRepository extends Repository { @Override boolean getHistoryGet( BufferSink sink, String parent, String basename, String rev) { String fullpath; try { fullpath = new File(parent, basename).getCanonicalPath(); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString()); return false; } HistoryRevResult result = getHistoryRev(sink::write, fullpath, rev); if (!result.success && result.iterations < 1) { String origpath; try { origpath = findOriginalName(fullpath, rev); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get original revision: {0}", exp.getClass().toString()); return false; } if (origpath != null && !origpath.equals(fullpath)) { result = getHistoryRev(sink, origpath, rev); } } return result.success; } MercurialRepository(); @Override Annotation annotate(File file, String revision); @Override boolean fileHasAnnotation(File file); @Override boolean fileHasHistory(File file); @Override boolean isWorking(); @Override String determineCurrentVersion(CommandTimeoutType cmdType); }
MercurialRepository extends Repository { @Override boolean getHistoryGet( BufferSink sink, String parent, String basename, String rev) { String fullpath; try { fullpath = new File(parent, basename).getCanonicalPath(); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get canonical path: {0}", exp.getClass().toString()); return false; } HistoryRevResult result = getHistoryRev(sink::write, fullpath, rev); if (!result.success && result.iterations < 1) { String origpath; try { origpath = findOriginalName(fullpath, rev); } catch (IOException exp) { LOGGER.log(Level.SEVERE, "Failed to get original revision: {0}", exp.getClass().toString()); return false; } if (origpath != null && !origpath.equals(fullpath)) { result = getHistoryRev(sink, origpath, rev); } } return result.success; } MercurialRepository(); @Override Annotation annotate(File file, String revision); @Override boolean fileHasAnnotation(File file); @Override boolean fileHasHistory(File file); @Override boolean isWorking(); @Override String determineCurrentVersion(CommandTimeoutType cmdType); static final String CMD_PROPERTY_KEY; static final String CMD_FALLBACK; static final String NOFOREST_PROPERTY_KEY; }