private String getPatch(long revA, long revB) throws SVNException, UnsupportedEncodingException { // Prepare required arguments. SVNURL svnURL = SVNURL.fromFile(getDirectory()); // Get diffClient. SVNClientManager clientManager = SVNClientManager.newInstance(); SVNDiffClient diffClient = clientManager.getDiffClient(); // Using diffClient, write the changes by commitId into // byteArrayOutputStream, as unified format. ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); diffClient.doDiff( svnURL, null, SVNRevision.create(revA), SVNRevision.create(revB), SVNDepth.INFINITY, true, byteArrayOutputStream); return byteArrayOutputStream.toString(Config.getCharset().name()); }
@Override public String getPatch(String commitId) throws SVNException { // Prepare required arguments. SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName)); long rev = Integer.parseInt(commitId); // Get diffClient. SVNClientManager clientManager = SVNClientManager.newInstance(); SVNDiffClient diffClient = clientManager.getDiffClient(); // Using diffClient, write the changes by commitId into // byteArrayOutputStream, as unified format. ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); diffClient.doDiff( svnURL, null, SVNRevision.create(rev - 1), SVNRevision.create(rev), SVNDepth.INFINITY, true, byteArrayOutputStream); return byteArrayOutputStream.toString(); }