Tuesday, March 29, 2005

Version the file system not the files

Most version control software misses the point. They version the files fine. Most fail to sufficiently version the file system.

When you are working on a codebase you want to be able to write new classes, rename them, move them to other assemblies, etc. A single class (throughout it's life) may have lived in various diffrent directories, in varously named files.

SourceSafe allows you to rename files or directories, but once they are renamed it is as if they have always had that name. If you ask for an old version, it still has the new name. Not what you want.

Subversion is better. It remembers the file's filename and content, so getting a version as of a past date works correctly. However subversion still required you to use subversion to rename the file otherwise it can't track the change. What if you are using a refactoring tool or IDE that does the file renaming for you?

What is needed is a version control system that watches the changes you are making to the filesystem as a whole and tracks these changes for later. Renaming a file on the hard drive should be enough for the verison control software to know the file was renamed.

Last weekend I have started a small application that attempts to achieve this goal. SVNMirror.

SVNMirror mirrors all changes made to a directory (and all subdirectories) in subversion. Here is how it works...

SVNMirror watches a source directory for changes (using the .Net FileSystemWatcher classes). SVNMirror is also given a versioned directory (which would usually be your working directory if you were using Subversion in the standard way). When a change occures the change gets mirrored in the versioned directory.

For example:

* You create a new file in your source directory. SVNMirror copies the file to your versioned directory and tells subversion to add the file to version control.
* You modify a file in your source directory. SVNMirror copies the change to your versioned file.
* You delete a file in your source directory. SVNMirror marks the file as deleted in subversion.

There are still a few issues with renaming files that are not comitted to the database yet, but other than that the proof of concept works fine. :)

I'll post a link to the page once I make a site for the project.

1 comment:

Anonymous said...

Actually, what you want is a method of tracking the classes, independent of the file they're in. That would be cool!

GitHub Projects