[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: "svn tree"

From: Carsten Koch <Carsten.Koch_at_icem.com>
Date: 2006-02-13 18:48:53 CET

Phil Endecott wrote:
...
> I wondered about "svn ls -R --xml | something", but it looks as if the XML doesn't actually have the recursive structure! It is just a flat list. So "something" would be more complex.

I do not think this would be hard,
but see below.

> The other problem with my setup is that "svn ls -R" is slow. I think that this is because it does lots of small http requests, and my mod_auth_pam authentication takes a noticeable time for each one. Or something like that.
>
> I just thought I'd mention it here in case anyone has found a good way to do this.

Yes, "svn ls -R" is terribly slow.
See this
http://subversion.tigris.org/servlets/ReadMsg?listName=users&msgNo=35618
and this
http://subversion.tigris.org/servlets/ReadMsg?listName=dev&msgNo=103390
thread.

I believe Jean-Marc Godbout has created a patch that speeds things up
quite a bit, but

1) his patch does not achieve a factor of 100,
    which IMHO would be reasonable.
2) AFAIK, his patch never got integrated.

As a workaround, we created a tiny cgi-bin shell script that
uses "svnlook tree" directly on the repository to output the tree.
This works with subversion as it is and it also does achieve
the factor 100 speed up.

I am using the following python function to connect to
the server, get the tree listing and convert it back to
the "svn list -R" output format:

def list_r(url):
    """ get a recursive listing of url. """
    list_lines = []
    try:
       import httplib
       # open a connection to cgi-bin/svndir, which returns a directory tree
       # with leading spaces that indicate the depth.
       url_components = url.split('/')
       connection = httplib.HTTPConnection(url_components[2])
       connection.request("GET", "/cgi-bin/svndir?" + '/'.join(url_components[3:]))

       # Convert into the format returned by svn list.
       path = []
       for entry in connection.getresponse().read().splitlines():
          spaces = entry.count(' ')
          path = path[0:spaces]
          if entry[-1] == '/':
             path = path + [entry[spaces:-1]]
             list_lines.append('/'.join(path) + '/')
          else:
             list_lines.append('/'.join(path + [entry[spaces:]]))
       connection.close()
       list_lines.sort()
    # Do not care what went wrong.
    # In any event try using svn list -R if cgi-bin/svndir fails to return lines.
    except:
       pass

    if list_lines == []:
       print "svndir returned no entries. Falling back to svn list."
       list_lines = subprocess.Popen("svn list -R " + url, shell=True,
              stdout=subprocess.PIPE).stdout.read().splitlines()
    return list_lines

Carsten.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Feb 13 18:54:12 2006

This is an archived mail posted to the Subversion Users mailing list.