SVNKitRepositoryService extends AbstractRepositoryService { protected String createUnifiedDiff(final PathRevision from, final PathRevision to, final String charset, final TextFile leftFile, final TextFile rightFile) throws IOException { final ByteArrayOutputStream diffResult = new ByteArrayOutputStream(); final DiffProducer diffProducer = new DiffProducer(new ByteArrayInputStream(leftFile.getContent().getBytes()), new ByteArrayInputStream(rightFile.getContent().getBytes()), charset); diffProducer.doUnifiedDiff(diffResult); final String diffResultString = diffResult.toString(charset); if ("".equals(diffResultString)) { throw new IdenticalFilesException(from.getPath() + ", " + to.getPath()); } return diffResultString; }  @Override LogEntry getLogEntry(final SVNConnection connection, final RepositoryName repositoryName, final long revision); @Override final List<LogEntry> getLogEntriesFromRepositoryRoot(final SVNConnection connection, final long fromRevision,
                                                              final long toRevision); @Override List<LogEntry> getLogEntries(final SVNConnection connection, final RepositoryName repositoryName,
                                      final long fromRevision, final long toRevision, final String path,
                                      final long limit, final boolean stopOnCopy, boolean includeChangedPaths); @Override final void export(final SVNConnection connection, final List<PathRevision> targets, final long pegRevision,
                           final File exportDirectory); @Override void getFileContents(final SVNConnection connection, final String path, final long revision,
                              final OutputStream output); @Override final Properties listProperties(final SVNConnection connection, final String path, final long revision); @Override final Long getLatestRevision(final SVNConnection connection); @Override final DirEntry.Kind getNodeKind(final SVNConnection connection, final String path, final long revision); @Override Map<String, DirEntryLock> getLocks(final SVNConnection connection, final String startPath, final boolean recursive); @SuppressWarnings({"unchecked"}) @Override final DirList list(final SVNConnection connection, final String path, final long revision); @Override final DirEntry getEntryInfo(final SVNConnection connection, final String path, final long revision); @SuppressWarnings({"unchecked"}) @Override final List<FileRevision> getFileRevisions(final SVNConnection connection, final String path, final long revision); @Override final String diffUnified(final SVNConnection connection, final PathRevision from, final PathRevision to,
                                  final Revision pegRevision, final String charset); @Override final List<DiffStatus> diffPaths(final SVNConnection connection, final PathRevision from, final PathRevision to); @Override final AnnotatedTextFile blame(final SVNConnection connection, final String path, final long revision,
                                       final String charset, final Colorer colorer); @Override Revision translateRevision(final SVNConnection connection, final Revision revision, final long headRevision); @Override List<Long> getRevisionsForPath(final SVNConnection connection, final String path, final long fromRevision,
                                        final long toRevision, final boolean stopOnCopy, final long limit);  }
@Test public void testDiffUnifiedIdenticalEmptyFiles() throws Exception { final SVNKitRepositoryService service = new SVNKitRepositoryService(); final PathRevision from = PathRevision.parse("/bug/code/try2/OrderDetailModel.java@91"); final PathRevision to = PathRevision.parse("/bug/code/try2/OrderDetailModel.java@90"); try { service.createUnifiedDiff(from, to, ENCODING, new TextFile(""), new TextFile("")); fail("Exception expected"); } catch (IdenticalFilesException e) { } }
@Test public void testDiffUnifiedIdenticalFiles() throws Exception { final SVNKitRepositoryService service = new SVNKitRepositoryService(); final PathRevision from = PathRevision.parse("/bug/code/try2/OrderDetailModel.java@91"); final PathRevision to = PathRevision.parse("/bug/code/try2/OrderDetailModel.java@90"); try { final String contents = "test file contents"; service.createUnifiedDiff(from, to, ENCODING, new TextFile(contents), new TextFile(contents)); fail("No result should be produced for identical files"); } catch (IdenticalFilesException e) { } }