Deleting Directories from Subversion Increases Size of Repository

Nothing great about this post, but during one of the training sessions a few days ago, a colleague was concerned about the number of branches we keep in our Subversion repository, and he said why can’t we just delete those unused branches/done-with-it branches so as to reduce the space utilization.

I told him that deleting these branches wouldn’t reduce the the space used by this repo on the server, instead, it actually increases. He’d a sarcastic sigh on his face! I told him, it is only the client that is benefited if number of branches(Or directories) to show-up in the Repo Browser  is less. I guess, it takes less time if there are 10 branches/directories to show, than  when there are 100.

Given that nothing added to version control(at least SVN) can ever be removed by a normal user(well, if you really want to remove some file/dir, there are ways to do it. Resort svndump, and svndumpfilter), logically, it is obvious that to stop the client from showing a particular directory that is removed, on the server, there has to some entry that says this deleted dir no longer exists in the head revision. And that some new entry definitely adds a few bytes of data.

Here is some proof:

D:\Repositories\DELETE_INCREASES_SIZE is where the data is stored physically, on my laptop(which is acting as server) for this test repo.

When a client requests to access my repo via URL https://GNQ85BS.net/svn/DELETE_INCREASES_SIZE/
the server actually reads the data from the above directory, and lets the client display it in the form of repository.

C:\Users\venkrao>svn co https://GNQ85BS.net/svn/DELETE_INCREASES_SIZE/

Checked out revision 0.

C:\Users\venkrao>cd DELETE_INCREASES_SIZE

The size of the repo on the server is given below:

C:\Users\venkrao\DELETE_INCREASES_SIZE>D:\fun\Tools\du.exe D:\Repositories\DELETE_INCREASES_SIZE

Du v1.5 - report directory disk usage
Copyright (C) 2005-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

Files:        27
Directories:  11
Size:         28,911 bytes
Size on disk: 1,51,552 bytes

--------------------------------------------------------------------------------

Now, I import some data into the repository(ie. add data to repo)

C:\Users\venkrao>svn import -m "" D:\userdata\venkrao\Downloads\blogger-importer
.0.5 https://GNQ85BS.net/svn/DELETE_INCREASES_SIZE/
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\blogger-importer-blogitem.php
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\blogger-importer.php
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\languages
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\languages\blogger-importer.pot
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\oauth.php
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\blogger-importer.css
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\blogger-importer-sanitize.php
Adding         D:\userdata\venkrao\Downloads\blogger-importer.0.5\blogger-import
er\readme.txt

Committed revision 1.

------------------

Now, size of the dir that physically holds this data ON THE SERVER(ie. my laptop), obviously increases.

C:\Users\venkrao\DELETE_INCREASES_SIZE>D:\fun\Tools\du.exe D:\Repositories\delete_increases_size

Du v1.5 - report directory disk usage
Copyright (C) 2005-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

Files:        30
Directories:  11
Size:         64,174 bytes
Size on disk: 1,96,608 bytes

C:\Users\venkrao\DELETE_INCREASES_SIZE>svn log https://GNQ85BS.net/svn/DELETE_INCREASES_SIZE/
------------------------------------------------------------------------
r1 | test | 2013-04-04 22:41:27 +0530 (Thu, 04 Apr 2013) | 1 line

------------------------------------------------------------------------

C:\Users\venkrao\DELETE_INCREASES_SIZE>svn ls https://GNQ85BS.net/svn/DELETE_INCREASES_SIZE/
blogger-importer/

NOW, I delete the data from the repo. See what happens to size of the dir that holds the data physically.
It actually increases. BECAUSE, it has to make *SOME* new entries(in layman terms) in the server, that tells the clients that this
data is removed from the repo in some revision, however, they are in fact present in the older revisions.

C:\Users\venkrao\DELETE_INCREASES_SIZE>svn del -m "Deleting to see if size of repo on the SERVER, increases" https://GNQ85BS.net/svn/delete_increases_
size/blogger-importer/

Committed revision 2.

-----------
Notice that the size of my repo dir on server has increased by 354 bytes.
C:\Users\venkrao\DELETE_INCREASES_SIZE>D:\fun\Tools\du.exe D:\Repositories\delete_increases_size

Du v1.5 - report directory disk usage
Copyright (C) 2005-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

Files:        32
Directories:  11
Size:         64,528 bytes
Size on disk: 2,04,800 bytes

C:\Users\venkrao\DELETE_INCREASES_SIZE>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s