import java.io.ByteArrayOutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
public final class SvnUtils {
private SvnUtils() { }
public static List<String> getChangeLog(String url, String username, String password, Date oldRevisionDate, Date newRevisionDate) throws SVNException, IOException {
DefaultSVNOptions svnOption = new DefaultSVNOptions();
svnOption.setAuthStorageEnabled(false);
svnOption.setUseAutoProperties(false);
svnOption.setKeepLocks(false);
SVNClientManager clientManager = SVNClientManager.newInstance(svnOption, username, password);
try (ByteArrayOutputStream result = new ByteArrayOutputStream()) {
SVNURL svnUrl = SVNURL.parseURIEncoded(url);
SVNRevision oldVersion = SVNRevision.create(oldRevisionDate);
SVNRevision newVersion = SVNRevision.create(newRevisionDate);
clientManager.getDiffClient().doDiff(svnUrl, newVersion, oldVersion, newVersion, SVNDepth.INFINITY, false, result);
Charset charset = SVNFileUtil.isWindows ? Charset.forName("gbk") : StandardCharsets.UTF_8;
return Arrays.asList(new String(result.toByteArray(), charset).split(System.lineSeparator()));
} finally {
clientManager.dispose();
}
}
}