The blog of Rahoul Baruah from 3hv Ltd

What's going on?

My name is Rahoul Baruah (aka Baz) and I'm a software developer in Leeds (England).

This is a log of things I've discovered while writing software in Ruby on Rails. In other words, geek stuff.

However, I've decided to put this blog on ice - I would ask you to check out my business blog here (or subscribe here).

03 February, 2007

Excursion on the Subversion

Have you ever used Microsoft Structured Storage? It is a COM API that allows access to 'files and folders' within a single file-system entity. For example, Word documents were structured storage - so all those embedded images and version history are stored as separate, accessible streams within a .DOC file. The API is actually quite easy once you get your head round it, but, like many COM APIs, it feels extremely complicated to use.

Apple (or more correctly NeXT) got around the same problem in a totally different way - using 'bundles'. These are basically folders, not files. However, the (FTF)Finder treats them as a single file. Double click an RTFD file and it opens in TextEdit as if it were a normal document. Right-click and select 'show package contents' and you see that it is actually a set of folders, with your text, embedded images and so on. And because bundles basically use standard file system semantics, there is no complex API to learn.

However, structure storage works nicely with version control - just treat it as a binary file. Bundles almost work nicely with version control. svn add document.lineform treats your Lineform file as a folder and then adds its contents in the same way as any other folder.

I quite happily added a load of documents into subversion the other day and then made the mistake of moving them in the Finder. I successfully removed the old location from the repository. But whenever I tried to add the "new" copy I would get 'document.lineform is already under version control'. Yet a status command showed a question mark - meaning that the file needed adding.

It took me a while to figure it out, but eventually I got there. When you use subversion it creates a hidden .svn folder inside every folder. This creates all the status files - details of modifications, the original version and so on. And as bundles are treated by subversion as folders, they get these invisible folders as well. So when I moved my 'file' it copied these hidden folders as well. Hence subversion thought my file had already been added - it had subversion's fingerprints all over it.

The solution? A quick rm -R -f document.lineform/.svn wipes out the hidden folder and we are back to normal.

No comments:

eXTReMe Tracker