Sunday, 30 January 2011

Subversion move + Sparse checkout

Recently i was given the task of moving the tags to another location with in the repository. Without much thought i wrote a shell script to do svn move from URL to URL i.e URL -> URL: complete server-side rename.

The script did the part well, but this resulted in spamming the mailbox. As each move is a server side rename which resulted in a commit and the post commit hook will send mail for each commits. Within 15 minutes i made 320 commits. But this was only the 1/4 of the move there were hundreds of tags to be moved. Then one of the subversion developer after seeing the series of commit mails, gave me a suggestion. First he asked to do the move in the working copy i.e WC -> WC: move and schedule for addition (with history)

this will result in a single commit ,but still this had a problem as i need to checkout the whole repository to make this move in the working copy. My repository is huge in size, so this is gonna take more time, but subversion had a solution for this too called sparse checkout. This option allows to checkout/update according to the depth we desire. So i made a svn co --depth empty, this gave me just the empty directories in no time, then i entered the source directory from where the tags needs to be moved, and then got the list of directories to be moved using svn list command and then did a svn update %DIR% --depth empty and then did a svn move of the source directory to the destination directory. I did this using a shell script. In 30 minutes all my directories were moved and scheduled for addition and removal from the source directory. Then i did a commit where all the move was done in a single commit. I wasn't aware that doing a sparse checkout/update and moving the directory will move all of its contents, even though if it's not available in the working copy. That's a good learning i had, hence sharing with you.

No comments:

Post a Comment