public ByteArrayOutputStream getDiff(String text) throws IOException { File pathToFile = new File(checkoutdir, fileName); SVNDiffClient diffClient = new SVNDiffClient(manager, svnOption); FileUtils.writeStringToFile(pathToFile, text, "UTF-8"); ByteArrayOutputStream diff = new ByteArrayOutputStream(); try { diffClient.doDiff(pathToFile, SVNRevision.UNDEFINED, SVNRevision.WORKING, SVNRevision.HEAD, SVNDepth.INFINITY, true, diff, null); } catch (SVNException e) { log.error("Diff fail", e); } return diff; }
public static ByteArrayOutputStream diff( SVNClientManager clientManager, File baseDir, SVNRevision startRevision, SVNRevision endRevision ) throws SVNException { ByteArrayOutputStream result = new ByteArrayOutputStream(); /* * SVNRevision.HEAD means the latest revision. * Returns SVNCommitInfo containing information on the new revision committed * (revision number, etc.) */ clientManager.getDiffClient().doDiff( baseDir, startRevision, startRevision, endRevision, true, true, result ); return result; }
doDiff(url1, rN, url2, rM, SVNDepth.getInfinityOrFilesDepth(recursive), useAncestry, result);
doDiff(url, pegRevision, rN, rM, SVNDepth.getInfinityOrFilesDepth(recursive), useAncestry, result);
doDiff(url, pegRevision, rN, rM, SVNDepth.getInfinityOrFilesDepth(recursive), useAncestry, result);
doDiff(url1, rN, url2, rM, SVNDepth.getInfinityOrFilesDepth(recursive), useAncestry, result);
@Override public String getDiff(SVNRepository repository, String path, List<Long> revisions) { SVNRevision min = SVNRevision.create(revisions.stream().min(Long::compare).get() - 1); SVNRevision max = SVNRevision.create(revisions.stream().max(Long::compare).get()); ByteArrayOutputStream output = new ByteArrayOutputStream(); try { getDiffClient(repository).doDiff( SVNUtils.toURL(repository.getUrl(path)), max, min, max, SVNDepth.EMPTY, false, output ); } catch (SVNException ex) { throw translateSVNException(ex); } return Utils.toString(output.toByteArray()); }
private String getDiffText(SVNRepository repository, SVNURL url, SVNLogEntryPath entry, long revision) { try { SVNClientManager clientManager = SVNClientManager.newInstance(null, repository.getAuthenticationManager()); SVNDiffClient diffClient = clientManager.getDiffClient(); ByteArrayOutputStream out = new ByteArrayOutputStream(); SVNRevision startRevision = SVNRevision.create(revision - 1); SVNRevision endRevision = SVNRevision.create(revision); diffClient.doDiff(url, startRevision, startRevision, endRevision, SVNDepth.FILES, true, out); String diffText = out.toString("UTF-8"); if (diffText.length() > MAX_SIZE_OF_A_DIFF) { log.error("diffs for " + entry.getPath() + " too big"); diffText = "-- TOO BIG --"; } return diffText; } catch (Exception e) { return ""; } }
/** * show diff between local file and repository file. * * @param file file to get diff * @return string diff * @throws VCSException */ @Override public String getDiff(File file) throws VCSException { String diff = null; try { ByteArrayOutputStream byte1 = new ByteArrayOutputStream(); SVNDiffClient diffClient = getSVNManager().getDiffClient(); diffClient.doDiff(file, // File path1, SVNRevision.HEAD, // SVNRevision rN, file, // File path2, SVNRevision.WORKING, // SVNRevision rM, SVNDepth.IMMEDIATES, // SVNDepth depth, false, // boolean useAncestry, byte1, // OutputStream result, null); // Collection changeLists diff = byte1.toString(); byte1.close(); } catch (SVNException e) { throw new VCSException(t("isisfish.vcs.vcssvn.diff.error"), e); } catch (IOException e) { throw new VCSException(t("isisfish.vcs.vcssvn.diff.error"), e); } return diff; }
public void diff(String target1, Revision revision1, String target2, Revision revision2, String outFileName, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws ClientException { SVNDiffClient differ = getSVNDiffClient(); differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted); differ.getDiffGenerator().setForcedBinaryDiff(force); SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(revision1); SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(revision2); try { OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if(!isURL(target1)&&!isURL(target2)){ differ.doDiff(new File(target1).getAbsoluteFile(), rev1, new File(target2).getAbsoluteFile(), rev2, recurse, !ignoreAncestry, out); }else if(isURL(target1)&&isURL(target2)){ SVNURL url1 = SVNURL.parseURIEncoded(target1); SVNURL url2 = SVNURL.parseURIEncoded(target2); differ.doDiff(url1, rev1, url2, rev2, recurse, !ignoreAncestry, out); }else if(!isURL(target1)&&isURL(target2)){ SVNURL url2 = SVNURL.parseURIEncoded(target2); differ.doDiff(new File(target1).getAbsoluteFile(), rev1, url2, rev2, recurse, !ignoreAncestry, out); }else if(isURL(target1)&&!isURL(target2)){ SVNURL url1 = SVNURL.parseURIEncoded(target1); differ.doDiff(url1, rev1, new File(target2).getAbsoluteFile(), rev2, recurse, !ignoreAncestry, out); } SVNFileUtil.closeFile(out); } catch (SVNException e) { throwException(e); } }
File path = paths[i]; try { doDiff(path, pegRevision, rN, rM, depth, useAncestry, result, changeLists); } catch (SVNException svne) { dispatchEvent(SVNEventFactory.createErrorEvent(svne.getErrorMessage()));
File path = paths[i]; try { doDiff(path, pegRevision, rN, rM, depth, useAncestry, result, changeLists); } catch (SVNException svne) { dispatchEvent(SVNEventFactory.createErrorEvent(svne.getErrorMessage(), null));
public void diff(String target, Revision pegRevision, Revision startRevision, Revision endRevision, String outFileName, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws ClientException { SVNDiffClient differ = getSVNDiffClient(); differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted); differ.getDiffGenerator().setForcedBinaryDiff(force); SVNRevision peg = JavaHLObjectFactory.getSVNRevision(pegRevision); SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(startRevision); SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(endRevision); try { OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if(isURL(target)){ SVNURL url = SVNURL.parseURIEncoded(target); differ.doDiff(url, peg, rev1, rev2, recurse, !ignoreAncestry, out); }else{ differ.doDiff(new File(target).getAbsoluteFile(), peg, rev1, rev2, recurse, !ignoreAncestry, out); } SVNFileUtil.closeFile(out); } catch (SVNException e) { throwException(e); } }
OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if (!isURL(target1) && !isURL(target2)) { differ.doDiff(new File(target1).getAbsoluteFile(), rev1, new File(target2).getAbsoluteFile(), rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, SVNURL url1 = SVNURL.parseURIEncoded(target1); SVNURL url2 = SVNURL.parseURIEncoded(target2); differ.doDiff(url1, rev1, url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out); } else if (!isURL(target1) && isURL(target2)) { SVNURL url2 = SVNURL.parseURIEncoded(target2); differ.doDiff(new File(target1).getAbsoluteFile(), rev1, url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists)); } else if (isURL(target1) && !isURL(target2)) { SVNURL url1 = SVNURL.parseURIEncoded(target1); differ.doDiff(url1, rev1, new File(target2).getAbsoluteFile(), rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists));
OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if (!isURL(target1) && !isURL(target2)) { differ.doDiff(new File(target1).getAbsoluteFile(), rev1, new File(target2).getAbsoluteFile(), rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, SVNURL url1 = SVNURL.parseURIEncoded(target1); SVNURL url2 = SVNURL.parseURIEncoded(target2); differ.doDiff(url1, rev1, url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out); } else if (!isURL(target1) && isURL(target2)) { SVNURL url2 = SVNURL.parseURIEncoded(target2); differ.doDiff(new File(target1).getAbsoluteFile(), rev1, url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists)); } else if (isURL(target1) && !isURL(target2)) { SVNURL url1 = SVNURL.parseURIEncoded(target1); differ.doDiff(url1, rev1, new File(target2).getAbsoluteFile(), rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists));
public void diff(String target, Revision pegRevision, Revision startRevision, Revision endRevision, String relativeToDir, String outFileName, int depth, String[] changelists, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws ClientException { SVNDiffClient differ = getSVNDiffClient(); differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted); differ.getDiffGenerator().setForcedBinaryDiff(force); differ.setOptions(getOptions()); SVNRevision peg = JavaHLObjectFactory.getSVNRevision(pegRevision); SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(startRevision); SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(endRevision); try { differ.getDiffGenerator().setBasePath(getDiffBasePath(relativeToDir)); OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if (isURL(target)) { SVNURL url = SVNURL.parseURIEncoded(target); differ.doDiff(url, peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out); } else { differ.doDiff(new File(target).getAbsoluteFile(), peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists)); } SVNFileUtil.closeFile(out); } catch (SVNException e) { throwException(e); } finally { resetLog(); } }
public void diff(String target, Revision pegRevision, Revision startRevision, Revision endRevision, String relativeToDir, String outFileName, int depth, String[] changelists, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws ClientException { SVNDiffClient differ = getSVNDiffClient(); differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted); differ.getDiffGenerator().setForcedBinaryDiff(force); differ.setOptions(getOptions()); SVNRevision peg = JavaHLObjectFactory.getSVNRevision(pegRevision); SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(startRevision); SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(endRevision); try { differ.getDiffGenerator().setBasePath(getDiffBasePath(relativeToDir)); OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if (isURL(target)) { SVNURL url = SVNURL.parseURIEncoded(target); differ.doDiff(url, peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out); } else { differ.doDiff(new File(target).getAbsoluteFile(), peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists)); } SVNFileUtil.closeFile(out); } catch (SVNException e) { throwException(e); } finally { resetLog(); } }
public void diff(String target, Revision pegRevision, Revision startRevision, Revision endRevision, String relativeToDir, String outFileName, int depth, String[] changelists, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws ClientException { SVNDiffClient differ = getSVNDiffClient(); differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted); differ.getDiffGenerator().setForcedBinaryDiff(force); differ.setOptions(getOptions()); SVNRevision peg = JavaHLObjectFactory.getSVNRevision(pegRevision); SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(startRevision); SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(endRevision); try { differ.getDiffGenerator().setBasePath(getDiffBasePath(relativeToDir)); OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName)); if (isURL(target)) { SVNURL url = SVNURL.parseURIEncoded(target); differ.doDiff(url, peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out); } else { differ.doDiff(new File(target).getAbsoluteFile(), peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out, JavaHLObjectFactory.getChangeListsCollection(changelists)); } SVNFileUtil.closeFile(out); } catch (SVNException e) { throwException(e); } finally { resetLog(); } }
private void doDiff(SVNDiffClient client, SVNLogEntry logEntry, SVNPath target, SVNDepth depth) throws SVNException { if (target.isFile()) { client.doDiff(target.getFile(), target.getPegRevision(), SVNRevision.create(logEntry.getRevision() - 1), SVNRevision.create(logEntry.getRevision()), depth, true, getSVNEnvironment().getOut(), getSVNEnvironment().getChangelistsCollection()); } else { client.doDiff(target.getURL(), target.getPegRevision(), SVNRevision.create(logEntry.getRevision() - 1), SVNRevision.create(logEntry.getRevision()), depth, true, getSVNEnvironment().getOut()); } }
private void doDiff(SVNDiffClient client, SVNLogEntry logEntry, SVNPath target, SVNDepth depth) throws SVNException { if (target.isFile()) { client.doDiff(target.getFile(), target.getPegRevision(), SVNRevision.create(logEntry.getRevision() - 1), SVNRevision.create(logEntry.getRevision()), depth, true, getSVNEnvironment().getOut(), getSVNEnvironment().getChangelistsCollection()); } else { client.doDiff(target.getURL(), target.getPegRevision(), SVNRevision.create(logEntry.getRevision() - 1), SVNRevision.create(logEntry.getRevision()), depth, true, getSVNEnvironment().getOut()); } }