@Test public void ParseALaSvn() throws Exception { String revId1 = "12345"; String author1 = "username1"; String date1= "2007-09-11T11:48:56.123456Z"; String file1 = "trunk/project/filename.ext"; String revId2 = "23456"; String author2 = "username2"; String date2= "2006-08-10T11:38:56.123456Z"; String file2 = "trunk/project/path/filename2.ext2"; String revId3 = "765432"; String author3 = "username3"; String date3= "2006-08-09T10:38:56.123456Z"; String output = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + " revision=\"" + revId1 + "\">\n" + "<author>" + author1 + "</author>\n" + "<date>" + date1 + "</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">" + file1 + "</path>\n" + "</paths>\n" + "<msg>* " + file1 + "\n" + " Description.\n" + "</msg>\n" + "</logentry>\n" + "<logentry\n" + " revision=\"" + revId2 + "\">\n" + "<author>" + author2 + "</author>\n" + "<date>" + date2 + "</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">" + file2 + "</path>\n" + "</paths>\n" + "<msg>* " + file2 +"\n" + " some comment\n" + " over several lines.\n" + "</msg>\n" + "</logentry>\n" + "<logentry\n" + " revision=\"" + revId3 + "\">\n" + "<author>" + author3 + "</author>\n" + "<date>" + date3 + "</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">" + file1 + "</path>\n" + "<path\n" + " action=\"A\">" + file2 + "</path>\n" + "</paths>\n" + "<msg>this is a longer comment - line1\n" + " that spans some lines,\n" + " three in fact - line3.\n" + "</msg>\n" + "</logentry>\n" + "</log>"; History result = instance.parse(output); assertNotNull(result); assertNotNull(result.getHistoryEntries()); assertEquals(3, result.getHistoryEntries().size()); String file1pref = Paths.get(Paths.get("/"+file1).toUri()).toFile().toString(); String file2pref = Paths.get(Paths.get("/"+file2).toUri()).toFile().toString(); HistoryEntry e1 = result.getHistoryEntries().get(0); assertEquals(revId1, e1.getRevision()); assertEquals(author1, e1.getAuthor()); assertEquals(1, e1.getFiles().size()); assertEquals(file1pref, e1.getFiles().first()); HistoryEntry e2 = result.getHistoryEntries().get(1); assertEquals(revId2, e2.getRevision()); assertEquals(author2, e2.getAuthor()); assertEquals(1, e2.getFiles().size()); assertEquals(file2pref, e2.getFiles().first()); HistoryEntry e3 = result.getHistoryEntries().get(2); assertEquals(revId3, e3.getRevision()); assertEquals(author3, e3.getAuthor()); assertEquals(2, e3.getFiles().size()); assertEquals(file1pref, e3.getFiles().first()); assertEquals(file2pref, e3.getFiles().last()); assertTrue(e3.getMessage().contains("line1")); assertTrue(e3.getMessage().contains("line3")); }
History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); } }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }  }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }  @Override void processStream(InputStream input); }
SubversionHistoryParser implements Executor.StreamHandler { History parse(File file, SubversionRepository repos, String sinceRevision, int numEntries, CommandTimeoutType cmdType) throws HistoryException { initSaxParser(); handler = new Handler(repos.getDirectoryName(), repos.reposPath, RuntimeEnvironment.getInstance().getSourceRootPath().length(), repos); Executor executor; try { executor = repos.getHistoryLogExecutor(file, sinceRevision, numEntries, cmdType); } catch (IOException e) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\"", e); } int status = executor.exec(true, this); if (status != 0) { throw new HistoryException("Failed to get history for: \"" + file.getAbsolutePath() + "\" Exit code: " + status); } List<HistoryEntry> entries = handler.entries; if (sinceRevision != null) { repos.removeAndVerifyOldestChangeset(entries, sinceRevision); } return new History(entries, handler.getRenamedFiles()); }  @Override void processStream(InputStream input);  }