46

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.)

Community
  • 1
  • 1
lamcro
  • 6,069
  • 18
  • 57
  • 70
  • By the way, do you have to do those searches often, or is it occasional? I'm thinking network and server load, maybe there are more optimal ways if you have to do regular queries. – RedGlyph Nov 07 '09 at 17:11
  • Just occasional, but any other options are welcome. – lamcro Nov 07 '09 at 17:23
  • Then it's not worth looking for something else ;-) But I don't think you'll escape the web content extraction - see below for a link to help do that in a script environment. – RedGlyph Nov 07 '09 at 17:29

7 Answers7

46

I was also looking to list repositories in SVN. I did something like this on shell prompt:

~$ svn list https://www.repo.rr.com/svn/main/team/gaurav

Test/
Test2/
Test3/
Test4/
Test5/
Test6/
John Conde
  • 217,595
  • 99
  • 455
  • 496
gkgarg24
  • 493
  • 4
  • 2
  • This sure looks like precisely what the OP asked for - a unix script way of getting a list of top level repositories. Would be nice to see it get accepted. – Jesse Chisholm Aug 28 '15 at 16:14
  • 17
    The `svn help list` output says `list (ls): List directory entries in the repository.`. To me, that suggests the `list` command only lists directories in the current repository. When I try `svn list https://your-svn-server/svn`, I get `svn: E170013: Unable to connect to a repository at URL 'https://your-svn-server/svn'`. I'm using Visual SVN Server 1.9.4 and the SVN 1.9.4 client on Windows. Lastly your example looks like it's listing files in the `gaurav` subdirectory inside the `main` repository. So this answer doesn't appear to provide a way to list all repos. Let me know if I'm wrong. – Sam Jul 25 '16 at 05:05
25

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
  • 29,093
  • 5
  • 52
  • 80
  • +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 Nov 07 '09 at 21:17
  • 1
    Exactly what I was looking for. Just point your browser to the root of the repository DAV and you've got the list. Belated +1 from me :) – ATaylor May 22 '13 at 07:32
  • 1
    so, in order to view the list we have to use browser? any alternative command lines? +1 btw, coz i am able to see via broswer.. but i'm still wondering if any command line exists :) – Amjo Jun 12 '16 at 09:24
  • I think it's worth clarifying that this setting enables **browser-based** repo listing. This is also confirmed by [the SVN book](http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html#svn.serverconfig.httpd.extra.browsing.reposlisting]). – Sam Jul 25 '16 at 05:26
2

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
  • 66,391
  • 18
  • 125
  • 167
  • I have to access it from a scripting language in unix, not from a web page. – lamcro Nov 07 '09 at 16:59
  • 1
    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 Nov 07 '09 at 21:46
1

At my company they didn't configure the server to provide a list of repositories, so svn list worked for a specific repository but not at a higher level to list all repositories.

However they installed FishEye which gives you a GUI listing the repositories https://www.atlassian.com/software/fisheye

It's a paid option, so it's not for everyone, but the functionality is nice.

Alex
  • 9,250
  • 11
  • 70
  • 81
0

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).

Community
  • 1
  • 1
RedGlyph
  • 11,309
  • 6
  • 37
  • 49
0

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
  • 6,853
  • 2
  • 26
  • 25
-1

Sometimes you may wish to check on the timestamp for when the repo was updated, for getting this handy info you can use the svn -v (verbose) option as in

svn list -v svn://123.123.123.123/svn/repo/path
Madhav Sbss
  • 325
  • 2
  • 7