views:

488

answers:

4

I'm looking for a way to search a whole subversion server.

I already got a piece of the puzzle to search within a repository. Now I need to do this for every repository.

Update:

I have to access this list from some unix shell script (perl, bash, etc.)

+1  A: 

Doesn't your access to SVN work just like a Web service? When I access the top directory of my SVN server, I get a page that's essentially a Table Of Contents of the whole works. It's an Unordered List that I can simply scan through.

EDIT: Here's how I would do it from the command line:

wget http://user:password@svn-url/ -O - | grep \<li\>
Carl Smotricz
I have to access it from a scripting language in unix, not from a web page.
lamcro
My answer updated to include a simple scripting option.
Carl Smotricz
If you access the svn repository via a different protocol than http(s) it doesn't work just like a web service. svn supports various other protocols, including its own one, file and svn+ssh.And in case you use http, it's a configuration option to (not) show the list of repositories on that server.
bluebrother
A: 

If your server is Apache, you should be able to configure it to see the repository list with viewvc - this is the most basic one, other more complex interfaces exist but this is not your purpose here.

In some versions, ViewVC is an option of the standard installation now, for instance from Collabnet.

Edit: Nevermind my previous idea just above, Peter has a much simpler way of sending the repository list.

From there, you will have to:

  • get the HTML page,
  • extract the list, and
  • process it for the individual repository search.

Unfortunately in this case I cannot think of something more straightforward.

There are examples on SO on how to extract text from HTML pages in Python, this would be a good option since Python also has bindings for SVN, to perform the repository search - you can still call svn directly from Python if you prefer.

If Python is not your cup of tea, you will have to process that differently with GNU tools (wget, then parsing tools or existing packages - I can't be of much help there, Carl gave you some more details in this post).

RedGlyph
+1  A: 

If you enable svn via apache and a SVNParentPath directive, you can add a SVNListParentPath On directive to your svn location to get a list of all repositories.

Your apache conf should look similar to this:

<Location /svn>
  DAV svn
  SVNParentPath         "/net/svn/repositories"
  # optional auth stuff     

  SVNListParentPath On    #  <--- Add this line to enable listing of all repos
</Location>
Peter Parker
+1... Ah, that's even easier than using viewvc then, I _thought_ I had seen that before but just couldn't find it back in my post! :-)
RedGlyph
A: 

If you know your way around Java, you can use SvnKit to do browse, search and God knows what with your Subversion server.

After that, you can package your program and invoke it either via an Ant task or a shell script.

It's quite a "brute force" solution, but once you master SvnKit, you can really do lots of cool things.

Vladimir