Saturday, June 04, 2005

WebDAV + Subversion

Lately I've been playing with the new autocommit features of Subversion 1.2.0, which allows Subversion to be used as a fully-functional WebDAV provider.

It sounds technical, and is an interesting toy to play with, but it's also really useful for me as a general user. What I now have is a folder on my home server, available online which I can use as any other directory and put files to. It's only accessible via SSL so only I can access it, and all accesses are encrypted to keep the contents of the folder secure.

That in itself is very useful for personal files, including my calendar which I can mount from something like Mozilla Sunbird, allowing me to access the same calendar file from work and home. But the really clever bit is that all changes made to the folder and its contents are fully versioned and tracked by Subversion transparently an automatically.

Take the case of my calendar. Imagine that I open the calendar file from work and add an event. Sunbird saves the new calendar file to the folder, and Subversion receives the new file and silently does a commit to the repository. Using Subversion's standard tools I can examine the repository and access any previous version of any file that has ever been stored in the folder.

To the general user the folder is just a folder, but effectively it has an automatic backup progress that backs up the file every time it changes.

Of course, this means the folder takes up more space than would be taken up by the files currently in it, but not as much as you think. Whenever a file is modified, Subversion only stores the differences between the old file and the new one. So in the case of my calendar change above, Subversion would only need to store the data representing the new event, and not the whole file again.

In terms of speed, using the WebDAV folder is slower than a local directory, but not much so. The slowest operation is saving a file, which involves transferring the file to the folder and waiting for Subversion to commit the change. It's not that slow, but slower than a normal save, making it less suitable for really large files. My use of SSL will also slow the process down somewhat.

In terms of what I use to get it working, the folder is served from Apache 2 with Subversion 1.2.0 underneath it.

On the client side there is davfs2 which allows a WebDAV resource to be mounted as a directory in the filesystem (though I can't figure how to get this to work with fstab).

For Windows there is the built-in WebFolders system, though this annoyingly doesn't yet allow you to map a network drive to the folder.

You can also gain read-only access to the current version of all files in the folder by just browsing to the folder's URL in any browser. This is a standard feature of Subversion which means you can quickly and easily get any file you like from anywhere without messing with local mounting.

Aside from the relatively minor issues mentioned above, the ability to securely share a folder from home accessible anywhere from the web and have it automatically version the changes is absolutely fantastic.

No comments: