Farrukh Qazi
Farrukh Qazi

Reputation: 41

SVN: list all branches of all projects in a respository

I have SVN repository setup and it has somewhat around 15 different projects. Each project has a similar structure i.e.

ProjectOne/
          tags/
          branches/
          trunk/

now, what I want to do is somehow list all the branches for all the projects in the repository. Is there a command or something I could use to do this? or going programmatically is the only option here ?

Upvotes: 3

Views: 7192

Answers (2)

RoboBear
RoboBear

Reputation: 5764

I believe this is the answer you're looking for:

svn ls URL-OF-REPO

and to find the REPO URL (If you don't know it already), you can use:

svn info .

inside the "current" SVN directory.

Alternatively, and more complicatedly, you can CLI-program the output to regex the URL too, as suggested in another posting:

svn info | grep URL | sed  's/URL: //g'

See these other StackOverflow posts for more information. Hope this helps!

  1. How to list all files in a remote SVN repository?
  2. How to get svn remote repository URL?

Upvotes: 3

bahrep
bahrep

Reputation: 30662

There is svn list command. Since you already know the URLs of your repositories and projects, just run it like this svn info https://svn.example.com/MyProject1/branches.

You could automate it using PowerShell. Here are two rough examples.

  • Use foreach loop to automate running svn list:

    $repos = "MyProject1", "MyProject2", "MyProject3", "MyProject4", "MyProject5"
    $rootURL = "https://svn.example.com/"
    
    foreach ($repo in $repos) {
    Write-Host -ForegroundColor Cyan "Repository: $rootURL/$repo `nBranches:"
    svn list $rootURL/$repo/branches
    }
    
  • Use xml'ed output of svn list and parse the output with Select-XML. You could customize the command to get latest revision, author and date&time.

    $repos = "MyProject1", "MyProject2", "MyProject3", "MyProject4", "MyProject5"
    $rootURL = "https://svn.example.com/"
    
    foreach ($repo in $repos) {
    Write-Host -ForegroundColor Cyan "Repository: $rootURL/$repo `nBranches:"
    ([xml](svn list $rootURL/$repo/branches --xml)).SelectNodes("//lists/list/entry").Name
    }
    

Note that both script samples will display only the branches that exist in HEAD (i.e. latest) revision.

Upvotes: 0

Related Questions