Alexander has posted 4 posts at DZone. You can read more from them at their website. View Full User Profile

SVNKit: Tame Subversion with Java!

02.26.2008
| 25318 views |
  • submit to reddit

SVNKit is an Open Source pure Java Subversion library. SVNKit literally brings Subversion, popular open source version control system, to the Java world.

With SVNKit you can do the following:

All standard Subversion operations:

For instance, the following snipped checks out project from repository:

   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:

   uc.doUpdate(dstPath, SVNRevision.HEAD, true); 

And finally commits local changes in "www" subdirectory if there are any:

   SVNCommitClient cc = cm.getCommitClient();
cc.doCommit(new File[] {new File(dstPath, "www")}, false, "message", false, true);

SVNKit supports all standard Subversion operations and compatible with the latest version of Subversion.

Access Subversion repository directly:

Some applications will benefit from working with repository directly, without keeping working copy locally. Example below displays list of files in "www" directory.

   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());
}

Direct repository access API allows to perform operations like update, commit, diff and many other. Additionaly to the performance benefits of the direct access to repository, this API makes it possible to version arbitrary objects or object models within Subevrsion repository, not only files from the file system.

Replace JNI Subversion bindings with SVNKit:

Native Subversion provides Java interface that works with Subversion binaries through JNI. In case you already using it or would like to use as an option, you may also use SVNKit through exactly the same interface. This way you'll let your application dynamically switch between JNI and SVNKit implementation of the same API or let your application work on the platforms where there are no native Subversion binaries. For example:

   // 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 is widely used in different applications, including IntelliJ IDEA, Eclipse Subversion integrations, SmartSVN, JDeveloper, bug tracking server side applications (e.g. Atlassian JIRA) and repository management and tracking tools (e.g. Atlassian FishEye) and many others.

Where to get more information:

Recently we've released SVNKit version 1.1.6 which is bugfix release. At http://svnkit.com/ you will find more information on that new version and, of course, downloads, documentation, source code example and articles explaining how to use SVNKit. In case of any questions you're welcome at our mailing list, or just contact us at support@svnkit.com

SVNKit is widely used in different applications, including IntelliJ IDEA, Eclipse Subversion integrations, SmartSVN, JDeveloper, bug tracking server side applications (e.g. Atlassian JIRA) and repository management and tracking tools (e.g. Atlassian FishEye) and many others.

With best regards,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!

0
Average: 5 (3 votes)
Published at DZone with permission of its author, Alexander Kitaev.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Lubos Pochman replied on Wed, 2008/02/27 - 9:33am

If you plan to use svnkit library in long running application, be aware, that the library has serious memory leak, and it will cause your application to run out of memory. I have reported the memory leak recently (uncovered by YourKit Profiler, thanks to YourKit for supporting open source!).

 

Alexander Kitaev replied on Wed, 2008/02/27 - 10:08am in response to: Lubos Pochman

Hello,

Is this problem reproducile with the latest version? We've fixed possible memory leak after version 1.1.4 - when using SVNKit through JavaHL API, in certain usage patterns, there indeed was one, but it should be fixed in 1.1.6 version of SVNKit. 

Anyway, probably every application does contain bugs, memory leaks, etc. SVNKit is implemented in a such way that it minimize the possibility of memory leak - no data is kept between operations, except for several connection and objects pools, so if there is still memory leak, I believe we will be able to fix it soon.

Thank you for reporting this problem.

Alexander Kitaev. 

Lubos Pochman replied on Wed, 2008/02/27 - 11:13am in response to: Alexander Kitaev

Alexander,

I have tested svnkit.jar 1.1.6 and the problems is still there. I have submitted an issue http://svnkit.com/tracker/view.php?id=221

I would be glad to help with resolving the issue, feel free to contact me if you need more info about the problem or if you need to test a new version of svnkit.jar. Note, that it is possible that the leak is triggered by specific use of svnkit in Luntbuild, so I have also included a link to the Luntbuild's Svn Adaptor in the issue.

And huge thanks for svnkit, it is great library!

Lubos Pochman 

Lubos Pochman replied on Thu, 2008/02/28 - 3:32pm

I have profiled my application (Luntbuild) with svnkit for 24 hours after adding manager.dispose() at the end of each svn action (log, checkout,...). The memory leak is gone.

Thanks to Alexander for his help, and thanks to svnkit devel team for great library.

 

Alessio Spadaro replied on Fri, 2008/02/29 - 7:26am

First thank you for this post and your excellent product.

I wonder if you plan to write something about arbitrary java object versioning. I read about it on your site but found no further informations.

 Regards,

    Alessio 

Aryasindhu Sahu replied on Thu, 2014/05/08 - 10:39am

Hi ,

I have tried to run the program using svnkit 1.8.5 but I am getting error : 

Exception in thread "main" org.tmatesoft.svn.core.SVNException: svn: E155017: Cant install D:\svnkit\www\rss2.php from pristine store, because no checksum is recorded for this file

Aryasindhu Sahu replied on Thu, 2014/05/08 - 10:39am

Hi ,

I have tried to run the program using svnkit 1.8.5 but I am getting error : 

Exception in thread "main" org.tmatesoft.svn.core.SVNException: svn: E155017: Cant install D:\svnkit\www\rss2.php from pristine store, because no checksum is recorded for this file

Pankaj Som replied on Wed, 2014/06/18 - 2:54am

 Hi Alexander,

Above shared info is really helpful for me.I appreciate your help if you provide me the java code of checkedin process in SVN server.


It is urgent for me.


Thankyou

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.