38

I access a large remote SVN repository. Since I usually only need a tiny subset of its content I did a "sparse checkout":

svn checkout --depth empty svn+ssh://... src

Whenever I need a folder from the repository I can just do

svn up folder

and when I don't need it anymore I use

svn up --set-depth exclude folder

But now I need a complete list of all the files in the repository and I don't want to do a complete checkout just to get the file and folder names.

I already tried svn ls -R which will indeed list some files I didn't check out but still there are some missing. I know because it does show everything in the current directory. Now I could semi-manually execute svn ls and svn up --depth empty for every new-found directory, but I wonder if there is some better alternative.

In contrast to How do I list all files ever committed to the repository? I'm only interested in the current content of the repository and I do not have access to svnadmin. Neither can I install software on the repository server.

Fritz
  • 1,293
  • 15
  • 27
Koma
  • 383
  • 1
  • 3
  • 5

5 Answers5

63

This lists all files recursively:

svn ls -R URL-OF-REPO
Florian Winter
  • 4,750
  • 1
  • 44
  • 69
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • 3
    Thanks! Explicitly using the repo URL did the trick. And yes, `-R` can be used. – Koma Feb 01 '13 at 13:23
  • 1
    FYI...Something that caused me to waste a lot of time is that SVN externals don't show in the output from the above command. Your directory structure of a working copy on disk won't match the output of 'svn ls' if you have externals. Keep that in mind if you are comparing them somehow as I was. – ehambright Sep 02 '22 at 16:42
10
svn list --recursive https://myrespository.my.com/Myproject

I think that works for current and all subdirectories as I tried. This one lists all branches and tags as well, and all their subdirectories and files.

Rodrigo Amaro Reveco
  • 4,932
  • 5
  • 22
  • 33
Gjordis
  • 2,540
  • 1
  • 22
  • 32
7

You can try my utility fast-svn-crawler, it is much faster than "svn list --recursive".

$ svn-crawler https://myrespository.my.com/Myproject
Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • 1
    Thanks for building this! A quick build note: On CentOS 6 box I had to modify the CMakeLists.txt file to change "include/apr-1.0" to "include/apr-1". – Matthew Ratzloff Apr 28 '14 at 22:57
  • Awesome tool. Is there a way to include file sizes as well? – Gray Fox Feb 17 '15 at 00:17
  • 1
    No, file sizes retrieving would require a separate request for each file; that would slow down the utility a lot. It could easily print [additionally] only "last changed revision", "last changed date", and "the author of the last change" (this information is in svn:entry:* properties that are received within the same request). – Dmitry Pavlenko Feb 17 '15 at 12:12
2

Without URL

svn list --recursive -r HEAD

sanrodari
  • 1,602
  • 2
  • 13
  • 23
2

If you want to get a complete list of all the files and not the folders, you can pipe svn list and grep command like this:

svn list -R svn://url/to/your/main/folder/on/repo | grep '[^\/]$'

the path to folders listed by

svn list -R svn://url/to/your/main/folder/on/repo

always ends with "/" while file path doesn't. The output is passed as an input to

grep '[^\/]$'

which excludes all the paths having a trailing "/"; the remaining paths are only related to files.

Example: let's assume we have a repository named myrepo on my.svnserver.com as a domain, and we want to get all the files listed in a subdirectory of myrepo i.e. mysubdir: the command is

svn list -R svn://my.svnserver.com/myrepo/mysubdir | grep '[^\/]$'

Also, if you pipe the result to wc -l command (which prints the number of newlines, as each output line contains one path only), you can get the number of all the files under mysubdir, like this

svn list -R svn://my.svnserver.com/myrepo/mysubdir | grep '[^\/]$' | wc -l
m3t4l
  • 41
  • 4