4

I'm searching for a library that can extract (at least) the following information from a SVN repository (not a working copy!):

  • Revision numbers and their author & commit message
  • Changes in each revision (added, deleted, modified files)

Is there a Python library that can do this?

For the authors and commit messages, I could parse "db/revprops/0/..." (simple format), but looking for changed files does not seem so easy, so I'd rather stick with a library that supports SVN repos.

AndiDog
  • 68,631
  • 21
  • 159
  • 205

2 Answers2

2

There are Python bindings to libsvn: http://pysvn.tigris.org/docs/pysvn.html. They facilitate doing pretty much everything the svn command line client can do.

In particular, the Client.log() method does what you are looking for.

Sven Marnach
  • 574,206
  • 118
  • 941
  • 841
  • `pysvn.Client().log("/var/svn-repos/name-of-repo-directory/")` always gives me the error "pysvn._pysvn_2_6.ClientError: '/var/svn-repos/name-of-repo-directory' is not a working copy". Are we talking about the same definition of "repository"? With repository, I mean the one with "conf", "db", "hooks" subdirectories, not the working copy. – AndiDog Dec 17 '10 at 16:06
  • @AndiDog: Try `pysvn.Client().log("file:///var/svn-repos/name-of-repo-directory/")`. That's actually something quite basic in svn: Plane paths are interpreted as working copies, URIs are interpreted as repositories. I assumed you to be familiar with this because it also holds for the svn command line client, but I probably should have mentioned it. – Sven Marnach Dec 17 '10 at 18:15
  • Cool, that works. I didn't know about the difference between URI style and plain paths (-> TortoiseSVN user :P). Thanks for that, I'll try tomorrow if I can extract the relevant information like this. – AndiDog Dec 17 '10 at 21:54
  • Tried it out now, both of my requirements can be met with `pysvn.Client().log("file:///path/to/repo", discover_changed_paths = True)`. Thanks for your help! – AndiDog Dec 18 '10 at 09:45
0

I think you want something like py-svn.

bhamby
  • 15,112
  • 1
  • 45
  • 66
  • I have already looked into its [programmer's reference](http://pysvn.tigris.org/docs/pysvn_prog_ref.html) and tested it, but it doesn't seem to be able to read repositories (only WCs). Correct me if I'm wrong. – AndiDog Dec 17 '10 at 14:58
  • @AndiDog: You are wrong. I have updated my answer to give a hint. – Sven Marnach Dec 17 '10 at 15:54