Subversion does not play tag

Thursday, 20 May 2010

Subversion is a fine version control system, but unlike most others it does not allow tagging of files and directories. Its so-called “tag” functionality is really just a kludge, but if you understand its limitations it can still be useful.

The operation that the SVN manual refers to as “tagging” is actually implemented by copying the “tagged” tree to a “tags” directory. But this isn’t really a tag. The original tree is unaffected: looking it it there is no way to tell that a tag was made.

That’s because a Subversion tag isn’t really a tag. It’s a snapshot: a copy of a tree at a particular point in time. This fulfils one of the main use cases for tags (reverting to or comparing with a specific release), but there are some problems.

First, you can’t easily find all the tags that have been applied to a tree or a file. You have to look at all the tags and determine what tree and revision they were copied from.

Second, a tag is just like any other directory tree; in particular, it can easily be modified, even accidentally. But a tag that can be modified is worthless.

I find it helpful to think of SVN “tags” as snapshots. It leads to a better intuition about how and how not to use them. This is especially useful when also working with other revision control system that implement real tagging.

I wish Subversion had implemented tagging more like Git, where a tag is simply a reference to a particular commit. Subversion could have implemented tags as, say, a path (like “/trunk” or “/branches/release-1”) and a revision number. These could be stored as metadata at the repository level, making it simple to manage them and match them up to revisions. And with tags tied to revisions there would be no way of accidentally changing a tagged tree.

I don’t suppose this feature will ever make it into SVN. Part of the reason is that they would have to come up with another name, since “tagging” is already taken by their non-tagging snapshot feature. So now SVN users think they know what tagging is, and people coming to Subversion from other version control systems end up being confused. If only the SVN team has had thought more about tags and snapshots then Subversion could have been a better system.

Tags: ,

Leave a comment