Subversion from Python

Generally, it’s preferable to bind to libraries rather than executables when given the option. In my case, I needed SVN access from Python and couldn’t, at that time, find a confidence-inspiring library to work with. So, I wrote svn.

It turns out that there is a Subversion-sponsored Python project. It looks to be SWIG-based.

This comes from the python-svn Apt package under Ubuntu.

The Programmer’s Guide has the following examples, among others:


import pysvn
client = pysvn.Client()
file_content ='file.txt')


import pysvn
client = pysvn.Client()
entry_list ='.')


import pysvn
client = pysvn.Client()
entry ='.')

Finding the Mime-Type of a File in Subversion

I’m not a fan of Subversion but it exists in my life nonetheless. To that end, sometimes you may need to write tools against it. Sometimes these tools may need to differentiate between binary and text entries. Since SVN needs to know, at the very least, whether a file is text or binary (because most version-control systems depend on taking deltas of text-files), it’s reasonable to think that you can read this information from SVN.

This information may be stored as a property on each entry. Note that though there appears to be no guarantee that this information is available, I consider it to be reasonable to expect that a binary file will always have a non-empty mime-type.

The mime-type of an image:

$ svn propget svn:mime-type image.png
$ echo $?

The mime-type of a plain-text file:

$ svn proplist config.xml
$ echo $?

Notice that you’ll get a successful return (0) whether that property is or is not defined.

You can also read the property off remote files in the same fashion:

$ svn propget svn:mime-type

Make Subversion Tags in Record Time

I, like most developers nowadays, despise Subversion. This is in no small part due to how much of a manual effort it is to properly tag your software. I still do it, but it makes me seeth with rage.

The svncl tool streamlines this. You simply give it the working-directory and the URL of the tags path within the repository, and it gives you a bulleted list of commit-messages that have occurred between the last tag and the current HEAD.

For example:

$ svncl .
- Setup fix.
- Removed obsolete references to collections package.
- Updates are now stored in S3.
- Added parallel S3 downloading.