How do I poll the subversion history/log remotely from python?
Question: I need to find the first committer of a branch without having to do a checkout
of all the entire branches. From command line that is very easy to do:

    
    
    svn log -v --stop-on-copy http://subversion.repository.com/svn/repositoryname
    

I need to do this from a python script, any idea how can I do that? I checked
the python subversion bindings but I cannot understand how to do it even if it
seemed it can be done.

Any help will be appreciated.


Answer: You could just use Python's
[`subprocess`](http://docs.python.org/library/subprocess.html#using-the-
subprocess-module) module:

    
    
    from subprocess import Popen, PIPE
    p = Popen('svn log -v --stop-on-copy http://subversion.repository.com/svn/repositoryname',
              stdout=PIPE)
    stdout, stderr = p.communicate()
    

This way you can run any SVN command you want: just examine `stdout` (and
perhaps `stderr`) to get the command's result. You could then use for example
a regex to parse the retrieved data:

    
    
    >>> s = Popen('svn log', shell=True, stdout=PIPE).communicate()[0]
    >>> m = re.search('\r\nr(?P<rev>\d+)\s+\|\s+(?P<author>\w+)\s+\|\s+(?P<timestamp>.*?)\s|', s)
    {'timestamp': '2011-10-10 10:45:01 +0000 (wed, okt 10 2011)',
     'rev': '1234',
     'author': 'someuser'
    }
    

