Mikkel Nielsen
Mikkel Nielsen

Reputation: 792

SVN Branch info from Java

I'm looking for a way to extract info on all branches within a repository. I'm only interesteted in the name of the branches.

I have tried to play around with SVNKit, but haven't been able to figure out, how to get this information.

Upvotes: 3

Views: 1791

Answers (3)

mstrap
mstrap

Reputation: 17413

If the repository structure is known, you may use either SVNLogClient.doList(SVNURL, SVNRevision, SVNRevision, boolean, boolean, ISVNDirEntryHandler) or you may go with the more low-level SVNRepository API directly. Have a look at the listEntries example at:

http://wiki.svnkit.com/Printing_Out_A_Subversion_Repository_Tree

Upvotes: 1

Andreas Dolk
Andreas Dolk

Reputation: 114757

From the svnbook, chapter 4:

You should remember two important lessons from this section. First, Subversion has no internal concept of a branch—it knows only how to make copies. When you copy a directory, the resultant directory is only a “branch” because you attach that meaning to it. You may think of the directory differently, or treat it differently, but to Subversion it's just an ordinary directory that happens to carry some extra historical information.

Second, because of this copy mechanism, Subversion's branches exist as normal filesystem directories in the repository. This is different from other version control systems, where branches are typically defined by adding extra-dimensional “labels” to collections of files. The location of your branch directory doesn't matter to Subversion. Most teams follow a convention of putting all branches into a /branches directory, but you're free to invent any policy you wish.

To get the branch names, you need to know information on the internat structure of a repository. I doubt, that there is a general approach to get all branches - as they are nothing but local copies.

Upvotes: 3

Alberto Gutierrez
Alberto Gutierrez

Reputation: 1588

Do ctrl+3 in your eclipse (BTW my favourite Eclipse shortcut), and type repositories, this should give you the option to open your SVN repository view.

Once the view is opened, if your repository is not added, add it... Once that is added you will be able to expand it and browse it as a normal directory tree and you will be able to see the name of all your branches

Upvotes: -1

Related Questions