Subversion is a file versioning tool that is widely used as the source code version management.
Existing tools, whether their own command-line tools or Windows UI TortoiseSVN, are also very handy, but if you want to integrate with the existing system, in addition to its built-in hook script function, it is necessary to use the SVN API, this API is written in C , so it is inconvenient for other languages such as Java, C #, and so on.
So, with the SVN client Java, or the other language to the C interface DLL package a layer of code (reference swig), so that we can easily use other languages to communicate with the SVN repository to the
SHARPSVN is an SVN API for the. NET platform, and it is widely used in tools such as ANKHSVN, which can be used to spread the custom visit to the SVN client or to integrate with other systems such as BUG/CR tracking.
Here's a simple guide for a web friend, like Hello World, telling us how to start using the sharp SVN
The SHARPSVN library basically gives you a. NET interface to all the operations so you would normally perform a Tool like TortoiseSVN.
I found myself needing this exact library while writing a tool that changes files that has been checked out from SVN.
The problem with manipulating files, is under SVN is, the need to be careful about renaming files (and sometimes Even deleting). If you don't do it through the SVN API then you'll end up with duplicates files/folders in SVN since SVN thinks that it ' s a new file.
To solve this I-finally got a chance to crack open the SHARPSVN library which are used by my favourite ankhsvn.
1. Download the latest library from http://sharpsvn.open.collab.net/. You had to pick between either 1.5 or 1.6. I went with 1.6 and didn ' t run to any issues. I think this was based on the version of the SVN server, your connecting to.
2. In your Visual Studio project add a reference to the following assemblies. -Sharpsvn.dll-sharpsvn.ui.dll (only needed if you need the UI to prompt for login)
3. If like me your building on a a-bit OS and you want your app to run on a + bit OS, make sure the project that Referen Ces the SharpSvn.dll is set-to-Build for the x86 Platform. (build–> Configuration manager–solution Platform)
4. Write your code using the Svnclient object. Here is some samples from the SHARPSVN Wiki and some that I wrote.
Showlog operation
using (svnclient client = new Svnclient ())
{//Client. Authentication.clear ();Client. Authentication.usernamepasswordhandlers + =New Eventhandler<sharpsvn.security.svnusernamepasswordeventargs> (Delegate (Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs ee) {ee. UserName ="Your account."; Ee. Password ="Your password."; });
Client. Authentication.sslservertrusthandlers + =New Eventhandler<sharpsvn.security.svnsslservertrusteventargs> (Delegate (Object ssender, SharpSvn.Security.SvnSslServerTrustEventArgs se) {//Look at the rest of the arguments of E whether your wish to accept
//If Accept:Se. Acceptedfailures = se. failures; Se. Save =True//Save Acceptance to authentication store});
This.txtLog.Text + = DateTime.Now.ToLongTimeString () +"\ r \ n"; Svnlogargs Logargs =New Svnlogargs (); Logargs.range =New Svnrevisionrange (Long. Parse (This.txtRevisionFrom.Text),Long. Parse (This.txtRevisionTo.Text)); Logargs.retrieveallproperties =True
Eventhandler<svnlogeventargs> Loghandler =New Eventhandler<svnlogeventargs> (DelegateObject lo, Svnlogeventargs le) {foreach (Svnchangeitem changeitemIn Le. Changedpaths) {This.txtLog.Text + =String. Format ("{0} {1} {2} {3} {4}\r{5} {6}", Changeitem.action, changeitem.path, changeitem.copyfromrevisiOn, Changeitem.copyfrompath, le. Author, le. LogMessage, &NBSP;&NBsp; le. Revision);
} });
Client. Log (New Uri (<a href="https://url" >https://url</a>), Logargs, Loghandler); This.txtLog.Text + = DateTime.Now.ToLongTimeString () + "\ r \ n"; }
using (svnclient client = new Svnclient ())
{//Client. Authentication.clear ();Client. Authentication.usernamepasswordhandlers + =New Eventhandler<sharpsvn.security.svnusernamepasswordeventargs> (Delegate (Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs ee) {ee. UserName ="Your account."; Ee. Password ="Your password."; });
Client. authentication.sslservertrusthandlers+=New Eventhandler<sharpsvn.security.svnsslservertrusteventargs> (Delegate (Object ssender, SharpSvn.Security.SvnSslServerTrustEventArgs se) {//Look at the rest of the arguments of E whether your wish to accept
//If Accept:Se. Acceptedfailures = se. failures; Se. Save =True//Save Acceptance to authentication store});
Client. CheckOut (New Uri ("Https://yourSVN-Server:8443/svn/prd/UTL/trunk/ExcelPool"),//SVN Repository URL @ "c:\wc"); //local direcotory }
Add new files to the working copy
using (svnclient client = new Svnclient ()) {Svnaddargs args = new Svnaddargs (); // Todo:set Optional settings on the args client. ADD (@ "C:\file\in\workingcopy", args);
}
Http://www.cnblogs.com/goody9807/archive/2012/11/01/2749938.html
The. NET interface of the SVN Client API SHARPSVN Introduction to checkout Operation example