由于工作需要通过JAVA获得SVN的提交记录,所以看了下SVNKit,
下面是代码,保存备份。
SvnKit项目地址:http://svnkit.com/index.html
package com.svnkit; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Set; import org.apache.log4j.Logger; import org.junit.BeforeClass; import org.junit.Test; import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.SVNWCUtil; public class SVNUtilTest { private static String url = "项目SVN路径"; private static SVNRepository repository = null; @BeforeClass public static void setupLibrary() { DAVRepositoryFactory.setup(); SVNRepositoryFactoryImpl.setup(); FSRepositoryFactory.setup(); try { repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); } catch (SVNException e) { logger.error(e.getErrorMessage(), e); } // 身份验证 ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("SVN用户名","SVN密码"); repository.setAuthenticationManager(authManager); } @Test public void filterCommitHistoryTest() throws Exception { // 过滤条件 final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); final Date begin = format.parse("2014-02-13"); final Date end = format.parse("2014-02-14"); final String author = ""; long startRevision = 0; long endRevision = -1;//表示最后一个版本 final List<String> history = new ArrayList<String>(); //String[] 为过滤的文件路径前缀,为空表示不进行过滤 repository.log(new String[]{""}, startRevision, endRevision, true, true, new ISVNLogEntryHandler() { @Override public void handleLogEntry(SVNLogEntry svnlogentry) throws SVNException { //依据提交时间进行过滤 if (svnlogentry.getDate().after(begin) && svnlogentry.getDate().before(end)) { // 依据提交人过滤 if (!"".equals(author)) { if (author.equals(svnlogentry.getAuthor())) { fillResult(svnlogentry); } } else { fillResult(svnlogentry); } } } public void fillResult(SVNLogEntry svnlogentry) { //getChangedPaths为提交的历史记录MAP key为文件名,value为文件详情 history.addAll(svnlogentry.getChangedPaths().keySet()); } }); for (String path : history) { System.out.println(path); } } }
相关推荐
SVNKit获取SVN信息
目前真正自己写的svnkit底层接口使用代码,svnkit很稳定,但接口使用说明不清晰,所以会导致了使用过程中会有很多的坑,实例中有完整的解决方法
其他SVNKit的操作包括CheckOut,DoCommit,DoDiff,DoImport,DoUpdate,查看上次备注信息(message/log),DisplayFile(查看svn文件属性)DisplayRepositoryTree(查看某路径下的所有文件)
svnKit java操作svn :上传 下载 提交 更新 版本
需要svnkit 使用方法 SVNUtil.getHistoryByDate("https://127.0.0.1:8443/svn/Test/mytestprotect/", "username", "password"); 如果jar 在我的其它资源里
SVNkit的Jar包 和实例代码 , 最新可用的, 自己找了好久的
svnkit是纯java实现的操作subversion的类库,使用起来非常的方便。官方文档提到,svnkit提供了三种类型的api:high level api、low level api和java hl api。本文简单介绍一下svnkit的high level api和low level api...
java调用SVNKit示例
SVNKit实例包括所有SVN相关的基本操作,完整项目,导入即可运行
SVNKit (JavaSVN) 是一个纯 Java 的 SVN 客户端库,使用 SVNKit 无需安装任何 SVN 的客户端,支持各种操作系统。 这不是一个开源的类库,但你可以免费使用。 通过SVNKit,你可以在SVN上开发出自己的应用
SVNKit开发手册,使用说明。类图介绍
svnkit1.3.5完整包svnkit1.3.5完整包
自己写的使用svnkit操作svn库,对比版本号、文件等等,并把需要的信息组装成json。
离线版svnkit帮助文档API,html
集成SVNKit检出以及获取比对不同文件清单小例子
svnkit-1.7.11
SVNKIT Java 示例, 文档附有Java 下载示例代码
,SVNKit1.7.9最新
svnkit,可以通过该jar获取svn上传历史信息,提交明细等。
svnkit-1.8.6.jar