Branching in Subversion


I'm just about to release Leonardo 0.4.0 so I thought I'd better learn how to branch in Subversion. Turned out to embarrassingly easy:

svn copy trunk branches/0.4

assuming you've got the entire tree checked out (otherwise it can be done almost as easily with URLs).

But it did get me thinking. Previously I've talked about replacing the structure recommended by the O'Reilly Subversion book

/branches /tags /trunk

with more explicit indications of what I use tags for:

/branches /checkpoints /milestones /releases /trunk

with further structure possible under the first four directories before getting to the actual source code.

Well, if I understand correctly, there is nothing special about the /trunk directory. I'm not even sure Subversion really has a notion of a trunk. So why not only have branches?

In other words, instead of keeping the latest development under /trunk and maintenance branches under /branches, why not have a branch for the current development version alongside the branches for maintenance. Something like:

/branches/0.4 /branches/0.5

where (in Leonardo's current state), next-version development takes place under /branches/0.5 and maintenance on 0.4 is done under /branches/0.4

Unless I'm missing something, this seems a clean way of organising things that is native Subversion. The original suggestion given by the Subversion book really makes sense only if you're coming from CVS.

Again, unless I'm missing something :-)

UPDATE (2004-12-23): Justin Johnson, in email noted:

The reason for using trunk is so that developers can continue working on the latest release without having to setup a new working copy everytime the project releases. For example, I were working on 0.4 and then 0.4 released and we created a 0.5 branch, I'd have to clobber my working copy and create a new one. But if I were looking at the trunk, I would be guaranteed that it always points to the latest release that is still in development. It may seem like a minor point, but when you have a lot of developers and when the size of the project is significant, it makes a huge difference.

This is a good point. I did consider the issue of "knowing which is the development branch" and that actually made me wonder about having aliases in Subversion.

However, in my own experience, for commercial software development at least, the developers (even on big projects) all know exactly what version is the latest development version and it is an important "event" in the engineering organization when a new branch is made.

I can see that, for distributed open source development, particularly if the cycles are short, a clearly designated trunk becomes more important, though.

The original post was in the categories: subversion software_craftsmanship but I'm still in the process of migrating categories over.