I recently started a new project on SourceForge, attempting to open the source of the content management system I’ve been developing for my current employer over the last few years. Unfortunately, the whole process of creating a new project on SourceForge caused more frustration than developing the CMS in the first place. While creating a new project is extremely simple, and uploading a packaged archive of your project’s files is easy, attempting to set up a new SVN repository so that you can begin versioning your application is beyond difficult (especially for a complete newbie to version control systems like me).
There are tutorials all over the Web that give you pieces of the information that you need, but I couldn’t really find any that gave me step-by-step instructions explaining how to turn the batch of source files I had on my hard drive to having a fully functional SVN repository containing those files on the SourceForge server.
In this article, I hope to walk you through the steps I took to get things set up initially. For the purposes of this article, I am assuming that you already have the initial source code on your computer. This article is intended for developers that have an established project, but don’t have versioning control set up.
To begin with, create a new directory on your hard drive to store the files you want to add to the repository. Copy your source files into that directory, make sure they are organized and that you’ve cleaned up a lot of the extraneous files that aren’t part of your project.
Then, you should visit Nikolai Shokhirev’s “Practical guide to subversion on Windows with TortoiseSVN”. Follow the steps he outlines there (especially the part in the “Step-by-step setup” section). Once you’ve followed his guide, you should have a new SVN repository set up on your computer.
For the next few steps, I didn’t find a good way to perform these tasks using Windows, so I had to fire up Linux in a virtual machine (VM). I used VirtualBox and made sure that the hard drive on which my new SVN repository is set up was listed as one of the VirtualBox “shared folders”.
Once the Linux VM is up and running (you can use a live disc so that you don’t have to go through the process of actually installing Linux on the VM), open up the terminal and mount the shared folder you set up in VirtualBox. Start by creating a new directory on the Linux drive so that the files have somewhere to go when you mount the drive. To do that, run a command similar to the following:
sudo mkdir /windows
That command will create a new directory called “windows” at the root of the Linux file system. In order to proceed, you will need to enter the “root” password for the Linux system.
Then, mount the VirtualBox shared folder in Linux by running a command similar to the following:
sudo mount.vboxsf cdrive /windows
In the example above, “cdrive” is the name that I assigned to the shared folder through VirtualBox. If you assign a different name to your shared folder, you’ll need to substitute that name in place of “cdrive”.
Once you’ve mounted the drive, you should now have access to your new SVN repository from within the VM. Now, you need to create a dump (backup) file of your repository. To do so, run a command similar to the following from within the terminal window:
svnadmin dump /windows/Projects/MyProject > /windows/Projects/MyProjectDump.bak
Obviously, if your SVN repository is located somewhere other than “\Projects\MyProject” on your Windows drive, you’ll need to adjust the location of the repository (the first argument after the “dump” command) and probably the location of the dump file (the second argument).
Once you have the dump file created, you should find the newly created file in Windows and zip it up using WinZip or a similar program.
Next, you’ll need to access the SourceForge Interactive Shell. Instructions for accessing the shell using PuTTY (as well as other SSH clients) can be found on the SourceForge wiki. If you are using PuTTY, be sure to follow all of the instructions provided in that section, as the connection will fail if you don’t set the “Connection > SSH” and “Connection > Data” settings properly.
Once you login to the Interactive Shell, you will need to start by typing sf-help to get information about connecting to your project folder through SFTP (you’ll need SFTP access in order to upload the dump file you created). When you type sf-help, you should see quite a few lines of output. Near the bottom of the output, you will see something along the lines of “For direct access to this shell, use shell2.sourceforge.net on port 22006“. The portions shown in red will be different for each user, so take note of those.
The next thing you will need to do is “checkout” the current repository on the SourceForge server. Assuming this is a new project, the repository should be completely empty, but you still need to check it out in order to work with it. You will check out the repository by executing the following command in the Interactive Shell session you have open in Windows:
adminrepo --checkout svn
Next, switch back over to your Linux VM (you can conceivably do this using an FTP client like Filezilla, but I found it easier to perform these actions using the Linux terminal) and type the following command:
sftp -o Port=22006 SFUSERNAME@shell2.sourceforge.net
Again, the portions highlighted in red will need to be modified to match your specific information.
Once you’ve connected successfully through SFTP, you now need to upload your dump file to the SourceForge server. To do so, use a command like the following:
put /windows/MyProjectDump.zip ./userweb/htdocs
That will upload the MyProjectDump.zip file to a folder on the SourceForge server that you should have permissions to write in.
Next, you should switch back to the Interactive Shell session you have open in Windows and unzip the dump file using the following commands (the first command moves you into the userweb/htdocs directory to make the rest of the actions easier):
Once the file has been unzipped, you can then load the contents of the dump file into your new SourceForge repository. To do so, you will need to run a command in the Interactive Shell session on Windows similar to:
svnadmin load /svnroot/PROJECTNAME < MyProjectDump.bak
Finally, you need to commit the changes you made to the repository. To do that, you will check the repo back in by running the following command in the Interactive Shell session on Windows.
adminrepo --save svn
Once you’ve followed all of those steps, you should have a brand new SVN repository on SourceForge that contains all of the files from your project.
Most of the SourceForge-related steps I described above can be found in the “Shell Service” and “Subversion Import Instructions” articles in the SourceForge wiki. More information about the command-line version of SFTP and its commands can be found in About.com’s article on SFTP.