Find file with given SVN URL in SVN working copy

Given the starting point in the Subversion working copy (for example, the current working directory) and the target SVN url, I would like to find a file in the working copy with the SVN url.

For example, given the current directory:

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

      

which has this SVN url:

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

      

I want to find a file on my hard drive with the specified 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

      

First, does the SVN API provide a function to do this? Second, if not, what's a good reliable (cross platform) method to implement it?

Python is my target language and I use pySvn, although the native SVN Python bindings might be an alternative.

+2


source to share


1 answer


Subversion does not use this backward mapping from url to the actual working copy location. The most stable way to check for URL usage is to recursively call "svn info" on the working copy.

This gives you the url for all files and directories and you can map accordingly.



You can optimize this a bit by trying to match urls on local paths and only look at sensible locations, but you will miss other places the "svn switch" generated.

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

+4


source







All Articles