Tuesday, November 22, 2011

Using Subversion without a Subversion server

For a while now I've been using Subversion locally for version control on some of my small projects, but recently realized that I've been using it in a way that many people may not know is possible.  I use Subversion without actually having a Subversion server anywhere in sight.  How is this possible?  Simple!

A Subversion repository is merely a set of files that hold all the information about the files, changes, and even users.  The Subversion server is merely a gateway between the client and the repository files.  If you take out the server and point the client directly the repository files, it will be right at home!

Some of the advantages of using Subversion this way are:

  • No software to install, configure, eat resources, or open any ports!
  • Flat file based.  Want to move your repositories elsewhere?  Just move the files!
  • Can place your repositories on a NAS device, USB drive, even USB memory stick.  Since there is no software, the NAS device doesn't have to have a built-in Subversion server or any junk like that.
  • Wanted them internet accessible.  I have my repositories placed on my NAS device, so if I am out and about and need to get an update, I can just VPN into my home router, and then access it on the NAS device as if I was at home on the network.

So how can you configure Subversion to work this way?  Follow these steps:

  1. Install TortoiseSVN.  It rocks.
  2. Go to a place where you want the repositories to reside.  These will not be your live usable files, these will be the files that are a part of the repository file structure.
  3. Create a new empty folder and use the name of the repository you want to create.
  4. Go into the folder, right click, and go to TortoiseSVN -> Create repository here.  Choose the Native filesystem.
  5. Go to where you want your live, usable files to be and create a new folder for them.
  6.  Go into the new folder, right click and go to SVN Checkout.  The URL of the repository will follow the "file://" pattern.  Your base URL is "file:///" (yes, three slashes).  From there, you will use your standard file path, leaving out any semi-colons (:) and changing "\" to "/".  So if you created a repository at D:\repositories\test, you would use "file:///d/repositories/test".  If you created the repository on another system or on a NAS device, where your address would normally be "\nas-device\repositories\test", you would use "file://///nas-device/repositories/test" (yup, 5 slashes).

One important thing to note about using Subversion this way is that there is limited security when working this way.  Anyone who has access to the files will be able to get the files and make check-ins.  If you wish to limit access, the best way would be through filesystem permissions.  Additionally, on a network share or NAS box, you could require user logins to get access to the files.  Another thing is that user tracking uses the username of the user on the Windows machine.  You can still track who checked in what, but it gets the username automatically, without doing any user authentication on the repository.  It will ignore the repositories conf\svnserve.conf and conf\passwd settings.

The URLs you enter may not be the clearest, but this is by far the simplest way to get up and going with Subversion for your own personal use.  My own repositories are kept on my NAS box, accessible from both my desktop and my laptop, and can even get on it remotely by VPN.  All with zero install and configuration.

No comments: