Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hooking into SVN in a asp.net web application

Tags:

c#

svn

How hard is it to create a repository via c#? What about viewing a source code file, or a diff, in a web app?

Is there an api I need to hook into or is it all custom code I have to write?

like image 881
mrblah Avatar asked Feb 28 '23 01:02

mrblah


1 Answers

SharpSVN provides you with a full API. It's not that easy to use and is generally quite slow unless you cache the items you get back.

SharpSvn is a binding of the Subversion Client API for .Net 2.0 applications contained within a set of xcopy-deployable dll's. Notable users of this api are (at this time):

  • AnkhSVN 2.X - Subversion Support for Visual Studio 2005 and 2008
  • CollabNet Desktop for Visual Studio
  • SharpDevelop (#develop)
  • MonoDevelop
  • SVN-Monitor
  • And many, many other projects..

Here's an example from an ASP.NET project I got about 50% through, that displayed all items from a repository:

using (SvnClient client = new SvnClient())
{
    client.LoadConfiguration(Server.MapPath("/"));
    SvnUriTarget target = new SvnUriTarget("http://wush.net/svn/yourusername/", SvnRevision.Head);
    SvnListArgs args = new SvnListArgs();

    Collection<SvnListEventArgs> svnList = new Collection<SvnListEventArgs>();
    client.Authentication.DefaultCredentials = new NetworkCredential("username", "password);
    args.Depth = SvnDepth.Children;
    client.GetList(target, args, out svnList);

    foreach (var item in svnList)
    {
        // display the list  
    }

}
like image 139
Chris S Avatar answered Mar 06 '23 05:03

Chris S