tags:

views:

649

answers:

9

I've been told that most development shops have the following structure or at least close to this:

  • Main Repository
    • Project folders underneath
    • Each Project folder has a trunk, branches, and tags folder

so:

ReponsitoryMain
    Project1
        branches
        trunk
        tags
    Project2
        ...

So why is this better or best? What happens or what heartaches have you come across if you did it another way?

+2  A: 

That's what we have. It works and that's good enough for now (because we never know what the future will bring) We don't have any compelling reasons to spend some valuable time (and money) to find a possibly more optimal structure.

M.

Max
I'm not debating the structure just wondering why it's recommended and what pitfalls you can get if you don't do it this way.
CoffeeAddict
+8  A: 

Most people do this because it's recommended by the Subversion book.

Here's a good explanation from the director of the CollabNet Subversion project:

http://blogs.open.collab.net/svn/2007/04/subversion_repo.html

ire_and_curses
nice link, thanks a lot. This is also very helpful.
CoffeeAddict
+4  A: 

We keep a separate repository for each project.

While this doesn't allow you to copy and keep the version history files from one project to another, it enables you to archive a whole repository when a project is over.

pgb
why would you want to archive it? Is that a Subversion command?
CoffeeAddict
just to save space, and keep it in a safe place instead of backing it up every day.
pgb
+1  A: 

Trunk branches and tags are all act the same way. How you use them is up to you.

I've been using this structure for years and have yet to find a time that the structure didn't adapt to what I needed to do.

Gren
+6  A: 

The repository structure depends on your needs. If your projects are fully separated (no dependencies between them) then this "simple" repository structure is fine. If you have dependencies in your project (eg some global "tool-libraries", shared code) you should use a different structure like:

trunk
   prj_a
   prj_b
tags
   <YOUR_TAGNAME>
       prj_a
       prj_b
branches
   <YOUR_BRANCHNAME>
     prj_a
     prj_b

or anything else which makes more sense to your process.

In the simple structure with local trunk/tags/branches it is not possible (at least in a clean way) to tag multiple projects, if you have dependencies between them.

Also the often proposed "Multi-repository" approach will not fill this gap as then you are doomed with multiple revisions or tags in multiple repositories.

The main problem is that SVN has NO support for shared ressources and tagging/branching them.

If you think about your Repository structure, you should ask yourself in what process you want to share your code libraries.

Peter Parker
when you say no support for shared resources. In my first example what if there is a Project 3 that both Project 1 and Project 2 uses meaning that Project 3 only has one solution in it.
CoffeeAddict
that is where the headache starts: you could use externals, but must be careful on tagging or branching, or you can use special checkoutscripts, however where to store them in your repository?I never found a perfect solution for shared resources in SVN. However you will quickly find a way to deal with them.
Peter Parker
+3  A: 

This way of organizing the repository:

ReponsitoryMain
    Project1
        branches
        trunk
        tags
    Project2
    ...

is best when your projects aren't that connected/dependent on each other. The other way around makes it easier to version your entire project suite. So if you often release/package Project1 and Project2 together, it's best to have them share the same branch.

If, on the other hand, your project are very decoupled and have totally different teams working on them, then you wouldn't need to check them all out together most of the time, and so you could use the above method.

Assaf Lavie
+5  A: 

Ok, I'm going to be a little more preachy and come down firmly on the side of having a trunk,tags & branches for each project.

The main alternative is to have a single trunk,tags & branches with all projects underneath. However, this leads to a number of problems, one of which is significant and I'll detail here:

Primarily it paves the way to the untouchable library, where everyone's scared to touch a particular library because any change may break something subtle in some random project. The cause of this is that because there's no separation between projects, anyone can effectively change the code in your project without you being able to either detect or control it.

What happens is that one day you check out your project and it builds, the next day you check it out and it fails, but you've made no changes to your project. What's happened is that someone has changed a library that you depended on. In a large structure with many dependencies, it's unrealistic for a developer to test their library changes against every project, especially if they have to make breaking changes. What you need in your project is a reference to a specific version of the library. That way, the library only gets updated when you change the reference to the latest version.

This kind of reference has 3 effects: 1 your project is isolated from random intermediate development changes to the library. 2 you get a revision in your project that tells you that "I'm now using this version of the library". 3. You get to control when you make the changes to your project to account for any breaking changes in the library.

There are other issues which I can go through if this isn't enough.

Jim T
+1  A: 

In systems like CVS, you didn't keep separate "directories". You just tagged and branched.

However, SVN is modelled more on the idea of snapshots, and therefore "copies" of stuff are done very efficiently. Rather than tagging or otherwise marking special (or alternate) versions of a project, it's easier (and more efficient) to make a named copy of it.

Tim Holloway
+2  A: 

At my shop, we have something like this:

RepositoryMain
  Trunk
    proj 1
    proj 2
    ..
  Dev
    Team1
      proj 1
      proj 2
    Team2
      proj 1
      proj 2
    ...

I don't know how this stacks up to most places but it seems to work pretty good

All the development teams can work separately on their own projects, merging from trunk to their project when they are beginning development/enhancement, and then merging back to trunk once they are finished.

Steven Wright
That is an interesting idea; it's almost like a Distributed Source Control System.
Frank V