How to get all branches of repository with SharpSvn?
Asked Answered
C

3

6

I'm trying to get all branches of repository by using SharpSvn but I can not find any method can do it.

Is it possible to get all branches by using SharpSvn?

Cangue answered 21/4, 2010 at 17:55 Comment(0)
U
4

I think Matt Z was on the right track, but that code doesn't compile. Here is an adjusted version that should work with the latest version of SharpSVN (as of Dec 2015).

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using SharpSvn;
....

private List<string> GetSVNPaths()
{
  List<string> files = new List<string>();
  using (SvnClient svnClient = new SvnClient())
  {
    Collection<SvnListEventArgs> contents;
    //you can get the url from the TortoiseSVN repo-browser if you aren't sure
    if (svnClient.GetList(new Uri(@"https://your-repository-url/"), out contents))
    {
      files.AddRange(contents.Select(item => item.Path));
    }
  }
  return files;
}
Unlock answered 23/12, 2015 at 20:7 Comment(0)
R
0

I don't know anything about SharpSVN, but branches in Subversion are just directory trees -- there's nothing special about them.

If your repository follows they typical layout with three top-level directories (trunk/ branches/ tags/), you can just check out the /branches directory to get all the branches side-by-side.

Runofthemill answered 21/4, 2010 at 18:3 Comment(0)
R
0

The SharpSvn.SvnClient class has a GetList() function that works really well:

using (SvnClient svnClient = new SvnClient())
{
    Collection contents;
    List files = new List();
    if (svnClient.GetList(new Uri(svnUrl), out contents))
    {
        foreach(SvnListEventArgs item in contents) 
        {
            files.Add(item.Path);
        }
    }
}

Once you have the collection, you can get the path of each item at the location. You can also use the Entry object to get information concerning each item, including whether it is a directory or a file, when it was last modified, etc.

Reflection answered 15/4, 2011 at 16:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.