sharpsvn

SharpSVN: Getting Entire Repository Structure


I looked at the following post (SharpSVN: Getting Repository Structure and Individual Files) and can successfully get the structure of my repository only at the main level. What I need to do is get the ENTIRE structure for every folder/subfolder under the main level. This is the code I have so far:

 Dim svnUrl As String = "https:\\SVN MAIN LEVEL REPOSITORY"
    Using svnClient As New SvnClient()
        Dim contents As Collection(Of SvnListEventArgs)
        Dim files As New List(Of String)()
        If svnClient.GetList(New Uri(svnUrl), contents) Then
            For Each item As SvnListEventArgs In contents
                'files.Add(item.Path)
                ListBox1.Items.Add(item.Path)
                TreeView1.Nodes.Add(item.Path)
            Next
        End If
    End Using

What am I missing or do I need to recursively call the function and pass in the levels?


Solution

  • I ended up writing my own recursive sub due to the specific requirements I had:

     If svnClient.GetList(New Uri(svnUrl), contents) Then
                ReDim Preserve node_array(UBound(node_array) + 1)
                node_array(UBound(node_array)) = LibraryNode.Text
                For Each SubFolder As SvnListEventArgs In contents
                    Dim MainNode As TreeNode = New TreeNode(SubFolder.Name)
                    If SubFolder.Name <> "My Top Level Folder" Then
                        ReDim Preserve node_array(UBound(node_array) + 1)
                        node_array(UBound(node_array)) = LibraryNode.Text & "\" & MainNode.Text
    
                        Dim thelevel As String = LibraryNode.Text & "\" & MainNode.Text
                        LibraryNode.Nodes.Add(MainNode)
                        currentlevel = 0
                        FillTreeViewNodesSVN(SubFolder.Uri.ToString, MainNode, svnClient, thelevel, currentlevel)
                    End If
                Next
            End If
    

    The above calls the recursion sub:

      Public Sub FillTreeViewNodesSVN(ByVal SubFolder As String, ByVal MainNode As TreeNode, ByVal svnClient As SvnClient, ByVal thelevel As String, ByVal currentlevel As Integer)
    
        Dim contents As Collection(Of SvnListEventArgs)
        Dim files As New List(Of String)()
        If svnClient.GetList(New Uri(SubFolder), contents) Then
            For Each item As SvnListEventArgs In contents
                If item.Uri.ToString <> SubFolder And InStr(item.Uri.ToString, "tag") > 0 Then
                    Dim SubNode As TreeNode = New TreeNode(item.Name)
                    ReDim Preserve node_array(UBound(node_array) + 1)
                    node_array(UBound(node_array)) = thelevel & "\" & SubNode.Text
    
                    thelevel = thelevel & "\" & SubNode.Text
                    currentlevel = currentlevel + 1
                    If currentlevel < 2 Then
                        FillTreeViewNodesSVN(item.Uri.ToString, SubNode, svnClient, thelevel, currentlevel)
                    End If
                    currentlevel = currentlevel - 1
                    thelevel = thelevel.Replace("\" & SubNode.Text, "")
                End If
            Next
        End If
    
    
    End Sub
    

    Combined the 2 create a node list of the folders 2 levels deep of ONLY the TAGS folder. This gets me all of the deployed TAGs for a given project.