onsdag 12. mai 2010

Essence of Subversion

My experience with Subversion was a bit confusing at first. I had used CSV before and tried to apply knowledge about it on svn, which didn't work well. But after a long time working with it, I think I got the essence of it.

Please type a comment if you find any errors :)

Essence of Subversion
  • an svn repository is basically a "hard drive", where the repository root is the root of the "disk". There is no such thing as a "module", "branch", "tag" nor "trunk". Everything is either a "folder" or a "file".
  • a "module", "branch", "tag" or "trunk" exists solely by naming convention and standard definition. Normal convention says that a module should be in a directory in the "root", branches should reside in a "[module]/branches" folder, tags in "[module]/tags" and trunk in "[module]/trunk".
  •  a repository has a single repository counter that is incremented for each commit. All files/dirs in a single commit is given the same number from this counter.
This means that a "tag" and a "branch" are essentially the same thing. The difference is that a tag (dir) is inside a folder named "tags", while a branch (dir) is inside the "branches" dir. Also, we accept content in a "branch" to be modifiable, but not files in a "tag".

The repository counter (a.k.a. revision number) can be viewed as "the number of times the repository has changed". If you check out the whole repository with rev #5, it means you will get the state of this "disk" after the 5th commit. To pick a specific version of a file, you need to know its location and the commit number for the wanted version.