SVNKit 是一个完全基于Java的Subversion开源工具库。SVNKit支持Java API控制和操作Subversion工作拷贝和资源。SVNKit支持http,https,svn和svn+ssh连接协议等。
通过SVNKit,你可以很容易的操作控制Subversion。
checks out project from repository:
Java代码
1. File dstPath = new File("c:/svnkit");
2. SVNURL url = SVNURL.
3. parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
4.
5. SVNClientManager cm = SVNClientManager.newInstance();
6. SVNUpdateClient uc = cm.getUpdateClient();
7. uc.doCheckout(url, dstPath, SVNRevision.UNDEFINED, SVNRevision.HEAD, true);
File dstPath = new File("c:/svnkit");
SVNURL url = SVNURL.
parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
SVNClientManager cm = SVNClientManager.newInstance();
SVNUpdateClient uc = cm.getUpdateClient();
uc.doCheckout(url, dstPath, SVNRevision.UNDEFINED, SVNRevision.HEAD, true);
Updates it to the latest revision:
Java代码
1. uc.doUpdate(dstPath, SVNRevision.HEAD, true);
uc.doUpdate(dstPath, SVNRevision.HEAD, true);
And finally commits local changes in "www" subdirectory if there are any:
Java代码
1. SVNCommitClient cc = cm.getCommitClient();
2. cc.doCommit(new File[] {new File(dstPath, "www")}, false, "message", false, true);
SVNCommitClient cc = cm.getCommitClient();
cc.doCommit(new File[] {new File(dstPath, "www")}, false, "message", false, true);
Access Subversion repository directly:
Java代码
1. SVNURL url = SVNURL.parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
2. SVNRepository repos = SVNRepositoryFactory.create(url);
3.
4. long headRevision = repos.getLatestRevision();
5. Collection entriesList = repos.getDir("www", headRevision, null, (Collection) null);
6. for (Iterator entries = entriesList.iterator(); entries.hasNext();) {
7. SVNDirEntry entry = (SVNDirEntry) entries.next();
8. System.out.println("entry: " + entry.getName());
9. System.out.println("last modified at revision: " + entry.getDate() +
10. " by " + entry.getAuthor());
11. }
SVNURL url = SVNURL.parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
SVNRepository repos = SVNRepositoryFactory.create(url);
long headRevision = repos.getLatestRevision();
Collection entriesList = repos.getDir("www", headRevision, null, (Collection) null);
for (Iterator entries = entriesList.iterator(); entries.hasNext();) {
SVNDirEntry entry = (SVNDirEntry) entries.next();
System.out.println("entry: " + entry.getName());
System.out.println("last modified at revision: " + entry.getDate() +
" by " + entry.getAuthor());
}
Replace JNI Subversion bindings with SVNKit:
Java代码
1. // pure Java implementation of the standard Subversion Java interface
2. SVNClientInterface jniAPI = SVNClientImpl.newInstance();
3. byte[] contents =
4. jniAPI.fileContent("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/changelog.txt",
5. Revision.HEAD);
// pure Java implementation of the standard Subversion Java interface
SVNClientInterface jniAPI = SVNClientImpl.newInstance();
byte[] contents =
jniAPI.fileContent("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/changelog.txt",
Revision.HEAD);
点击下图进入SVNKit官方网站
通过SVNKit,你可以很容易的操作控制Subversion。
checks out project from repository:
Java代码
1. File dstPath = new File("c:/svnkit");
2. SVNURL url = SVNURL.
3. parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
4.
5. SVNClientManager cm = SVNClientManager.newInstance();
6. SVNUpdateClient uc = cm.getUpdateClient();
7. uc.doCheckout(url, dstPath, SVNRevision.UNDEFINED, SVNRevision.HEAD, true);
File dstPath = new File("c:/svnkit");
SVNURL url = SVNURL.
parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
SVNClientManager cm = SVNClientManager.newInstance();
SVNUpdateClient uc = cm.getUpdateClient();
uc.doCheckout(url, dstPath, SVNRevision.UNDEFINED, SVNRevision.HEAD, true);
Updates it to the latest revision:
Java代码
1. uc.doUpdate(dstPath, SVNRevision.HEAD, true);
uc.doUpdate(dstPath, SVNRevision.HEAD, true);
And finally commits local changes in "www" subdirectory if there are any:
Java代码
1. SVNCommitClient cc = cm.getCommitClient();
2. cc.doCommit(new File[] {new File(dstPath, "www")}, false, "message", false, true);
SVNCommitClient cc = cm.getCommitClient();
cc.doCommit(new File[] {new File(dstPath, "www")}, false, "message", false, true);
Access Subversion repository directly:
Java代码
1. SVNURL url = SVNURL.parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
2. SVNRepository repos = SVNRepositoryFactory.create(url);
3.
4. long headRevision = repos.getLatestRevision();
5. Collection entriesList = repos.getDir("www", headRevision, null, (Collection) null);
6. for (Iterator entries = entriesList.iterator(); entries.hasNext();) {
7. SVNDirEntry entry = (SVNDirEntry) entries.next();
8. System.out.println("entry: " + entry.getName());
9. System.out.println("last modified at revision: " + entry.getDate() +
10. " by " + entry.getAuthor());
11. }
SVNURL url = SVNURL.parseURIEncoded("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/");
SVNRepository repos = SVNRepositoryFactory.create(url);
long headRevision = repos.getLatestRevision();
Collection entriesList = repos.getDir("www", headRevision, null, (Collection) null);
for (Iterator entries = entriesList.iterator(); entries.hasNext();) {
SVNDirEntry entry = (SVNDirEntry) entries.next();
System.out.println("entry: " + entry.getName());
System.out.println("last modified at revision: " + entry.getDate() +
" by " + entry.getAuthor());
}
Replace JNI Subversion bindings with SVNKit:
Java代码
1. // pure Java implementation of the standard Subversion Java interface
2. SVNClientInterface jniAPI = SVNClientImpl.newInstance();
3. byte[] contents =
4. jniAPI.fileContent("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/changelog.txt",
5. Revision.HEAD);
// pure Java implementation of the standard Subversion Java interface
SVNClientInterface jniAPI = SVNClientImpl.newInstance();
byte[] contents =
jniAPI.fileContent("http://svn.svnkit.com/repos/svnkit/branches/1.1.x/changelog.txt",
Revision.HEAD);
点击下图进入SVNKit官方网站