A site devoted to discussing techniques that promote quality and ethical practices in software development.

Monday, August 2, 2010

Important to set up a subversion repository correctly

To use Subversion effectively, one needs to sit down and plan the organization of the repository layout. "Version Control with Subversion" book page 16, recommends:
While Subversion's flexibility allows you to lay out your repository in any way that you choose, we recommend that you create a trunk directory to hold the “main line” of development, a branches directory to contain branch copies, and a tags directory to contain tag copies. For example:
$ svn list file:///var/svn/repos
/trunk
/branches
/tags
Failure to adhere to this recommendation can bring lots of grief later on. Often when you start off a project, you may not anticipate that you may need tags or branches and hence you start importing file directly into the repository at the root. Like this:

Then one day you decide to start using tags to record interesting events. Where do you now put it? Let's create a directory called Tags and put it there, like this:

Now you may think this fixes the problem. Not quite. If some one decides to check out the trunk, this is what you will end up with:

Now you do not only get the files for the trunk but also files associated with every tags you have in the repository. In this demo, I only have one tag.

While it is not a dead loss, you can still fix this situation. First get everybody to check in everything first.

Then create three separate directories in the repository, 2 are of immediate need, as Trunk, Tags and Branches directly below the root. Staying with the recommended names and structures benefit everybody and avoid misunderstanding.

Select all the trunk directories, excluding Branches, Trunk, or Tags folders, and move them into the Trunk sub-directory.

Check the Trunk out to a different directory on your local drive. it is best not to use your old copy anymore. Then tag that immediately so that you know this important event in correcting the repository directory structure. Of course you store the tag in the Tags sub-directory.

These steps are totally unnecessary if it is done immediate after the creation of the repository.

No comments:

Blog Archive