Thursday, December 27, 2012

Dropbox as SVN Repository


Version controlling is one of the most important concepts in software development. It helps us to maintain different version of files and folders in a very easy way among different peoples. One of the most popular versions controlling system is SVN. 

This post is not about describing the features of SVN, rather it will focus some advanced issues here.

The most critical (and important) problem I faced while working in online distributed team is to maintain the codes among my different team mates. Well, there are many free online SVN servers out there which will provide you space to store your SVN repository, but there is another way you can bypass those SVN server if you don’t want to put your code on their servers.

Below are the steps.

1. Setup environment

Download TortoiseSVN and install.

2. Create folder

2.1 Go to your Dropbox folder and create a new folder named 'DropboxSvnRepository'


3. Create repository

3.1 Right click on the 'DropboxSvnRepository' folder--TortoiseSVN-- Create Repository Here



3.2 Create the folder structures
Please copy the url of the respository as highlighted on the image. The url is “file:///E:/Online Backups/Dropbox/DropboxSvnRepository” for mine. Please keep in mind that I will refer this url later.  



4. Checkout

Create a folder at where you want to put the project/projects. In my case I have named it as 'DropboxSvnClient' under my E drive.
4.1 Right click--SVN Check out



4.2 Put/paste the url--press ok



4.3 Default folders of the repository will be downloaded to the Client folder.



5. Create folders

Now we need to create the folders according to our need. I will make this simple.
5.1 Go to trunk and create a folder named 'Projects'



5.2 Right click on the folder--TortoiseSVN—Add



Then press OK and OK on the following two windows.
5.3 You should see the following overlay icon with the Projects folder.



5.4 Right click on the same Projects folder--Commit
Press OK and OK to the next windows. The Projects folder should be green in color.



5.5 Now the Projects folder is copied to the repository folder. Since the repository folder is in Dropbox, it is syncing with online.




6. Create project

6.1 Open your visual studio. Create a console application. In my case it is 'CalculatorApplication' and put it inside of the Projects folder.



6.2 Make your Program class as given below.



7. Commit project

After successful compiling, you need to add this project to the svn.
7.1 Right click on the CalculatorApplication folder--TortoiseSVN—Add



7.2 Select the necessary folder. You can see below screenshot for help.
7.2.1 Uncheck the Resharper generated folders.



7.2.2 Uncheck Bin and Obj folders



7.2.3 Click OK and you should see the window confirming that the files is being added.



7.2.4 Press OK and you should see the following overlay icon with the CalculatorApplication folder.



7.3 Now we will commit the newly added files and folders.
7.3.1 Right click on the CalculatorApplication folder--SVN Commit
7.3.2 Write some notes for the commit you are doing and then press OK.



7.3.3 After successful commit, you should see your repository will syncing.

What is happening after you press commit?
This is a tricky part. Your files are copying from CalculatorApplication folder to your 'DropboxSvnRepository' folder. Since the later folder is inside of the Dropbox, the files will be uploaded to the Internet. 
If anyone gets this DropboxSvnRepository folder and also try to use that folder as a repository, he/she will get the files you have commit on your local repository. Thus any number of SVN user can work simultaneously using this repository under the SVN concept if he just gets the DropboxSvnRepository folder. They don't need a Online SVN Server to manage their code over internet.

[Now i am in my brother's computer.]

8. Remote machine

8.1 Now we should test it. I have shared the DropboxSvnRepository folder to my brother's account which Dropbox is installed in another computer. I downloaded the folder there.



9. Copy Repository Url

9.1 Right click on the repository—TortoiseSVN—Repo-browser



9.2 Copy the selected text and keep in mind it is the repository url.



10. Checkout

10.1 Create a folder at where you want to put the project/projects. In my case I have named it as 'FahimsDropboxClient'.



10.2 Right click--SVN Check out--put the appropriate url--press ok



11. Open project

11.1 You should see the similar folder structure created in the previous machine. Open the project you find on the Projects folder.



12. Change project

12.1 You should see the similar code written in the previous machine.



12.2 Change some code. Create a method like below.



13. Commit project

13.1 Build and Run the project. Since the only file we changed now is Program.cs file, so this file is now turned into red. 



13.2 Right click on the Program.cs file--SVN Commit
13.2.1 Since the latest file is now copying to the repository, the repository is syncing and the overlay icon turned into blue.



13.2.2 After syncing is complete, the file will be having green overlay icon.



14. Update my machine

Now we go to 1st location (my machine). The changed files are going to my machine’s local repository. Since this folder is in Dropbox, my brother’s folder will be synced with other shared Dropbox accounts like me or any others.

15. Update folders

15.1 Right click on the DropboxSvnClient--SVN Update.



15.2 The files which are changed on remote machines, will be updated by SVN in your local computer.



16. Test

Open the project and you should see the method which is added in the another machine.


Thus we can use a single Dropbox folder as a SVN repository without having any online SVN server.

4 comments:

Anonymous said...

SVN had lock on my folder so synchronization was delayed, and suddenly Dropbox merged two different versions of the repository - the entire thing was FUBAR.

Had to click folder, Shift+Delete, never doing this gaain.

Anonymous said...

This repo storage method is only reliable if you make sure that dropbox is turned off then sync with dropbox later.

Great article!

Anonymous said...

This was a very helpful blog. I've never used a repository before, and I just followed the instructions and it worked as I expected. I'm not sure what happened to the first person who commented, but my computers didn't hang. Both machines are Win7.

Anonymous said...

the chap up top got owned because this method is dodgy as hell, rather use git ! open source use github, private use bitbucket. Both are free