SVN Repository Search [closed]
Asked Answered
F

14

158

Is there any good software that will allow me to search through my SVN respository for code snippets? I found 'FishEye' but the cost is 1,200 and well outside my budget.

Froh answered 31/10, 2008 at 17:0 Comment(7)
Do you need to search through the history of the repo? Or just the head?Stanwood
There is a free version of FishEye - www.atlassian.com/starterGerhan
@DavidFreitas no free options nowPeggy
There is a $10 version of FishEye : www.atlassian.com/software/starter/overview, @bahrep. Once off, all proceeds to charity.Gerhan
There is new svn log --search option, may be handy for someone looking for simple repository history search.Peggy
This looks somewhat like a duplicate of how-do-i-search-all-revisions-of-a-file-in-a-subversion-repository.Gratiana
Move to git and github. :-)Index
H
72

If you're searching only for the filename, use:

svn list -R file:///subversion/repository | grep filename

Windows:

svn list -R file:///subversion/repository | findstr filename

Otherwise checkout and do filesystem search:

egrep -r _code_ .
Hesitate answered 17/6, 2010 at 18:24 Comment(3)
It may not be entirely obvious, but these commands apply to any method of accessing an svn server, not just file: (e.g. svn: and svn+ssh: also work)Scoles
// , Would you mind providing a working example for each of those?Reveal
OP wanted to search through the files, not just filenames. filesystem search example not very usefule.Modeling
S
37

There is sourceforge.net/projects/svn-search.

There is also a Windows application directly from the SVN home called SvnQuery available at http://svnquery.tigris.org

Swashbuckler answered 17/8, 2009 at 9:54 Comment(2)
I've just downloaded this myself - version 1.2.2.0 is currently available. (i.e. out of Beta)Stroh
New Source Forge URL for SVN Search: svn-search.sourceforge.netAttribute
P
13

Update April, 2022

VisualSVN Server 5.0 supports full-text repository search through the contents and history. Try out the new full-text search feature on the demo server.

Update January, 2020

VisualSVN Server 4.2 supports finding files and folders in the web interface. Try out the new feature on one of the demo server’s repositories!

See the version 4.2 Release Notes, and download VisualSVN Server 4.2.0 from the main download page.

enter image description here


Old answer

Beginning with Subversion 1.8, you can use --search option with svn log command. Note that the command does not perform full-text search inside a repository, it considers the following data only:

  • revision's author (svn:author unversioned property),
  • date (svn:date unversioned property),
  • log message text (svn:log unversioned property),
  • list of changed paths (i.e. paths affected by the particular revision).

Here is the help page about these new search options:

 If the --search option is used, log messages are displayed only if the
 provided search pattern matches any of the author, date, log message
 text (unless --quiet is used), or, if the --verbose option is also
 provided, a changed path.
 The search pattern may include "glob syntax" wildcards:
     ?      matches any single character
     *      matches a sequence of arbitrary characters
     [abc]  matches any of the characters listed inside the brackets
 If multiple --search options are provided, a log message is shown if
 it matches any of the provided search patterns. If the --search-and
 option is used, that option's argument is combined with the pattern
 from the previous --search or --search-and option, and a log message
 is shown only if it matches the combined search pattern.
 If --limit is used in combination with --search, --limit restricts the
 number of log messages searched, rather than restricting the output
 to a particular number of matching log messages.
Peggy answered 5/12, 2013 at 10:15 Comment(2)
This method works fast, but should not be used to search for the presence of files. As this search option only parses the list of explicitly changed paths in each revision, you can create folder copies (new branch created from trunk) where a certain file is present, but it won't be listed by this method.Endocrine
@Pieter-JanBusschaert your comment is about using the svn log --search command. See the updated answer about the new webui-based search. It does not have this limitation.Peggy
G
10

We use http://opensolaris.org/os/project/opengrok/

Goldfish answered 31/10, 2008 at 19:0 Comment(1)
OpenGrok has moved to opengrok.github.io/OpenGrok now.Mathilda
G
9
  1. Create git-svn mirror of that repository.
  2. Search for added or removed strings inside git: git log -S'my line of code' or the same in gitk

The advantage is that you can do many searches locally, without loading the server and network connection.

Glockenspiel answered 17/6, 2010 at 18:49 Comment(0)
K
9

This example pipes the complete contents of the repository to a file, which you can then quickly search for filenames within an editor:

svn list -R svn://svn > filelist.txt

This is useful if the repository is relatively static and you want to do rapid searches without having to repeatedly load everything from the SVN server.

Kink answered 10/10, 2013 at 13:31 Comment(2)
I should note that in my case, it was necessary to use http as the protocol (svn list -R http://repo/svn/etc).Durative
downvoted, because OP wanted to search through the files, not the filenames. The svn list command only dumps the filenames of the repository.Modeling
A
4

I do like TRAC - this plugin might be helpful for your task: http://trac-hacks.org/wiki/RepoSearchPlugin

Ashla answered 31/10, 2008 at 18:44 Comment(1)
this looks somewhat promising... but not too terribly easy to install, can't confirm if it works with Trac+VisualSVN Server.Koetke
G
4

Just a note, FishEye (and a lot of other Atlassian products) have a $10 Starter Editions, which in the case of FishEye gives you 5 repositories and access for up to 10 committers. The money goes to charity in this case.

www.atlassian.com/starter

Gerhan answered 8/7, 2010 at 13:9 Comment(2)
Not anymore? I don't see free options on the page.Peggy
@bahrep, I've updated the answer, it's now $10 which goes to charity which is effectively "free" if you think about it.Gerhan
M
3

Painfully slow (and crudely implemented) but a combination of svn log and svn cat works if you are searching the history of single files or small repositories:

svn log filetosearch |
    grep '^r' |
    cut -f1 -d' ' |
    xargs -i bash -c "echo '{}'; svn cat filetosearch -'{}'" 

will output each revision number where file changed and the file. You could always cat each revision into a different file and then grep for changes.

PS. Massive upvotes to anyone that shows me how to do this properly!

Malignity answered 31/10, 2008 at 20:13 Comment(1)
Just use git-svn. Git has built-in search for code in commit history. But you will need to download the whole commit history to use git-svn.Glockenspiel
B
2

If you're really desperate, do a dump of the repo (look at "svnadmin dump") and then grep through it. It's not pretty, but you can look around the search results to find the metadata that indicates the file and revision, then check it out for a better look.

Not a good solution, to be sure, but it is free :) SVN provides no feature for searching past checkins (or even past log files, AFAIK).

Bartolemo answered 31/10, 2008 at 19:16 Comment(1)
svnadmin must be executed on the server. You can use svnrdump on the client side. See https://mcmap.net/q/152653/-unable-to-do-an-svn-dump-error-e720002-and-format-errorsVirescence
T
1

A lot of SVN repos are "simply" HTTP sites, so you might consider looking at some off the shelf "web crawling" search app that you can point at the SVN root and it will give you basic functionality. Updating it will probably be a bit of a trick, perhaps some SVN check in hackery can tickle the index to discard or reindex changes as you go.

Just thinking out loud.

Trehalose answered 31/10, 2008 at 17:31 Comment(1)
This is probably not a good idea, as the overhead involved would be huge. Also, SVN-servers aren't usually regular web-pages, but a svn repo exposed through webdav.Heurlin
C
1

theres krugle and koders but both are expensive. Both have ide plugins for eclipse.

Citrange answered 31/10, 2008 at 17:43 Comment(1)
What about Krugle Basic?Haimes
H
1

I started using this tool

http://www.supose.org/wiki/supose

It works fine just lacking a visual UI, but is fast and somewhat maintained

Hartsfield answered 29/10, 2010 at 13:53 Comment(3)
Nowadays (August 2012) the project seems to have stalled...Osmanli
In December 2012 they released something new (0.7.1)Cadmann
seems to have disappeardWinfrid
S
0

// Edit: Tool was already mentioned in another answer, so give all credits to Kuryaki.

Just found SupoSE which is a java based command line tool which scans a repository to create an index and afterwards is able to answer certain kinds of queries. We're still evaluating the tool but it looks promising. It's worth to mention that it makes a full index of all revisions including source code files and common office formats.

Savell answered 28/6, 2011 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.