问题
We have a bulk repository for code contain thousands of folder and sub folder, i want to search under this repositor with file name or with some word.
Root folder
a\
b\
c\
d\
e\
f\ab\
f\ab\cd.txt
I want to search for cd.txt but dont know where it is in SVN Repository, for that i want to perform a search on the root folder of SVN where i will put the file name cd.txt and run the command, will check in each folder and will display the file details result....
Hope requirement is clear. Can you please help me on this.
回答1:
If the file is in your working copy, then if you are using svn 1.5:
svn list --depth infinity | grep <filename>
or an earlier version of svn:
find . -name <filename> -not -path '*.svn*'
If you need to find the file in history (deleted or moved):
svn log -v | less
and search for it with:
\<filename><return>
回答2:
The following works for me (svn version 1.4.6)
svn list -R <URL> | grep "<file_pattern>"
回答3:
With access to the repo itself use (i.e on your svn host file sytem)
svnlook tree [path_to_repo] | grep [file_name]
or to search all repos (if you have mulitple repos setup).
for i in \`ls [path_to_repos_dir]`; do echo $i; svnlook tree [path_to_repos_dir]/$i | grep -i [file_or_folder_name]; done
the option --full-paths will give the full path in repo to the file (if found)
example:
for i in `ls /u01/svn-1.6.17/repos`; do echo $i; svnlook tree --full-paths /u01/svn- 1.6.17/repos/$i | grep -i somefile.txt; done
redirect output to a file if static copy is needed.
assumes using nix OS.
回答4:
svn list --depth infinity <your-repo-here> to get a list of files in the repo, and then svn cat to get contents. You can add --xml key to list command to make parsing a bit simpler.
回答5:
Recently I've published my utility to list the repository, that's much faster than "svn ls --depth infinity" approach. Here're the benchmarks. It just calls a function that is available in Subversion internal API, but now accessible through a command line.
So you can run
$ svn-crawler <URL> | grep "<file_pattern>"
回答6:
If you are using TortoiseSVN you can try this IF you are willing to look Project by Project - works for me:
- Create a blank project under your repository top level URL, call it BLANK
- Click on the Repo URL on left pane
- On the right hand pane select your BLANK project and your desired project - say trunk
- Right click to pop up the browser menu and select 'Compare URLs', depending on the size of your repo it may take a minute to load. But you basically get your entire project list in a 'ready-to-search' list.
- Enter your file name or other string in the search filter
回答7:
If your's remote repository is not huge, then an easy method is: You can do a "checkout" to get a local repository. If you are in windows machine you use "Search" or Linux machine use "Find" command.
来源:https://stackoverflow.com/questions/704901/search-in-svn-repository-for-a-file-name