tags:

views:

276

answers:

1

Given a starting point in a Subversion working copy (e.g. current working directory), and a target SVN URL, I'd like to find the file in the working copy that has that SVN URL.

For example, given this current directory:

c:\Subversion\ProjectA\a\b\c\

which has this SVN URL:

https://svnserver/svn/ProjectA/trunk/a/b/c/

I'd like to locate the file on the hard drive with this target SVN URL:

https://svnserver/svn/ProjectA/trunk/a/x/y/test.txt

which in this example would be:

c:\Subversion\ProjectA\a\x\y\test.txt

Firstly, does the SVN API provide a function to do this? Secondly, if not, what is a good reliable (cross-platform) method to implement it?

Python is my target language, and I'm using pySvn although the native Python SVN bindings could be an alternative.

+3  A: 

Subversion doesn't use this backward mapping from url to working copy location itself. The most stable way to check for the url use would be to perform a recursive 'svn info' call over the working copy.

This gives you the url for all files and directories and you can do the matching yourself.

You could optimize this a bit by trying to map the urls on local paths and only look at sensible locations, but you would miss other locations created by 'svn switch'.

I don't know how 'svn info' is mapped in the python bindings, but there is most likely some info2() function on a client class you can use.

Bert Huijben