When a Subversion Repository is Missing the Standard Trunk/Tags/Branches Base Folders

Subversion is basically a fancy file system. When storing files in a Subversion repository, you can use any folder names you like. The convention is to have three top-level folders called “trunk”, “tags”, and “branches”, with the master copies of the project’s files under trunk. Making a tag is merely a matter of copying what’s in trunk to a subfolder of tags, and starting a branch is merely a matter of copying what’s in trunk to a subfolder of branches. There is absolutely no difference between tags and branches as far as Subversion is concerned. (Actually, you can tag or branch anything, not just what’s in trunk.) When I say, “copy”, I’m referring to the Subversion concept of “cheap copies.” Under the hood, the file contents and the differentials are all stored together. The observable file system is actually just lots and lots of pointers to the actual content.

Sometimes, mistakenly, Subversion repositories are created with all of the project files directly at the root level. So, what do you do when a Subversion repository is missing the standard trunk/tags/branches base folders and you want to create a tag or branch? The answer is simply to create a trunk folder and move the project files into it. For those of you with Windows workstations, the Repository Browser that comes with TortoiseSVN makes it a piece of cake, if just a bit tedious.

  1. In Windows Explorer, right click on any one of your project files or folders in your working directory and select TortoiseSVN | Repo-Browser.
  2. In the Repository Browser, right click on the project root and select Create Folder (not Add Folder).
  3. Name it “trunk” (lower case). Click OK.
  4. Change the default log message, if you wish. Click OK.
  5. Left drag each file and folder in the project root into the new trunk folder, until only the trunk folder remains. (This is the tedious part because shift-click doesn’t work here, so you have move them one at a time.)
  6. Create a “branches” folder and a “tags” folder (lower case, plural) alongside the trunk folder.
  7. IMPORTANT — After a switch, each developer has to redirect their working folder to point to trunk, but don’t be confused. You might think you need to use the Relocate command for this (TortoiseSVN | Relocate…), but you don’t. That’s for if the entire repository were to move to, say, a completely different server or a different port. Shifting things around within the repository only calls for the Switch command (TortoiseSVN | Switch…). Yes, that’s the same command to use for switching between tags & branches.

There’s only one tiny hitch with doing this. When you create the new trunk folder and then move everything into it, the trunk folder itself will only be associated with changes to its contents going forward. That is, if you try to view the log from trunk, you will not see any of the pre-trunk history of its contents. But don’t panic. Each file and subfolder still retains that history, as does the root folder which retains the history of everything. So, if you want to see a comprehensive history, you either have to open the repository browser and get the history from the root, or be content to look only at a particular sub-folder (e.g. src). After a while, you probably won’t care much about the pre-trunk history anyway.

Post a Comment

You must be logged in to post a comment.



© 2006-2007 Maxim Software Corp.  All rights reserved.