Manu
Manu

Reputation: 29143

how can I search an svn repository for the existence of files in any revision

How can I search if a file named foo.txt was ever committed to my svn repository (in any revision)?

Upvotes: 31

Views: 77872

Answers (4)

Johan Danforth
Johan Danforth

Reputation: 4579

I use powershell and the command svn list -R to search the repo recursively and then pipe the results into findstr or similar, like:

svn list -r HEAD -R | findstr /R /I "\/obj\$/ \/bin\/$"

Upvotes: 0

bahrep
bahrep

Reputation: 30662

Use Subversion 1.8+ client and new --search and --search-and options become available for svn log command. These options do not allow perform full-text search inside a repository and looks up 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).

As far as I guess, you can search for "foo.txt" with the following command line:

svn log -v --search "foo.txt".

Here is the complete help page about these new svn log 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.

Upvotes: 5

Martijn Laarman
Martijn Laarman

Reputation: 13536

Right click on the checked out folder's root > TortoiseSVN > Show Log

You can enter file names just as well there.

Upvotes: 41

Adam Bellaire
Adam Bellaire

Reputation: 110489

This should work for you:

svn log -r 0:HEAD -v $REPOSITORY_PATH | grep "/foo.txt"

This will give you the paths to the files and the state from the log. If you get any hits, you know it existed at some point. If you get no results, there is nothing matching anywhere in the repository at any revision. You'll also see the states from each log line, e.g.:

   A /some/path/foo.txt
   D /some/path/foo.txt

But I'm guessing the extra info isn't a problem for you. :)

Upvotes: 12

Related Questions