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();
}
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60