views:

378

answers:

4

Hi there,

I'm using Versions app on a mac to handle a SVN repository for my files. My working copy is around 6MB yet my repository is only 1.4MB, and I am holding 5 revisions in the repository!

How can this be?

Mike

+5  A: 

SVN compresses one version of your code the differences between each version. That is why it does not take much space.

To keep the repository small, Subversion uses deltification (or deltified storage) within the repository itself. Deltification involves encoding the representation of a chunk of data as a collection of differences against some other chunk of data. If the two pieces of data are very similar, this deltification results in storage savings for the deltified chunk—rather than taking up space equal to the size of the original data, it takes up only enough space to say, “I look just like this other piece of data over here, except for the following couple of changes.” The result is that most of the repository data that tends to be bulky—namely, the contents of versioned files—is stored at a much smaller size than the original full-text representation of that data. And for repositories created with Subversion 1.4 or later, the space savings are even better—now those full-text representations of file contents are themselves compressed.

More detail can be found here

NawaMan
+4  A: 

Your working copy normally contains a lot of additional temporary files such as object code and precompiled headers that are not required to be revision controlled. I guess if you clean the working copy, or make a new checkout it will be much smaller.

1800 INFORMATION
This is true, but for the reasons explained by Nawaman and wcoenen, even a newly checked out clean working copy with no generated files (such as precompiled headers and object code) may be significantly larger than the repository: the working copy has two copies of each file uncompressed (working and pristine), while the repository has 1 compressed copy of each file + deltafied changes (which can be very small if the changes were localized).
Stephen C. Steel
+1  A: 

Here are few reasons I can think of - svn stores your revisions as changesets and not versioned files. - svn stores data in its backend(FSFS/BDB) which has some compression techniques which reduces the size. If the repository has more text based files the more the compression is hence can expect a drastic decrease in size. - To support few commands(like svn info, diff, etc) without network connection (also to have faster results) svn maintains some extra information in the .svn dirs. The extra information includes a copy of the whole working copy.

Sivakumar
+4  A: 

Nawaman's answer already explained that the data in the repository is compacted quite efficiently.

The other half of the story is that subversion keeps a pristine copy of each file inside the .svn folders of your working copy. This enables subversion to handle svn status or svn diff commands without needing to contact the repository server, but it doubles the size of your working copy.

Wim Coenen