Wednesday, September 30, 2009

Subversion

I have not used source control systems much, and I am finding that setting it up, on a Windows machine, with open source IDE's (especially not Eclipse) is more painful than it should be - documentation somehow seems to assume you're either using Eclipse or a Unix system or both. Here is what seems to work for me:

  • install Subversion
  • create (in DOS) a directory where you will store the files: dirX
  • in DOS: svnadmin create dirX (e.g.: D:\svn)
  • in DOS: set EDITOR=notepad.exe
  • in DOS, D:\>svn mkdir file:///svn/python (if python is the sub directory where you want to store a project); using a \ (eg svn\python) will cause svn to fail with a weird assertion
  • do the initial load of the project in the subversion system: svn import D:\pythonsource\ file:///svn/python (assuming your project is in D:\pythonsource)
  • you will get a message in Notepad - close it, and choose [c] in DOS to continue the process of loading the directory into subversion
  • at this point you will have the original source, the subversion source, and when the IDE will check out from subversion it will create another project, so you can delete the initial source directory
  • you might want to only include the source files from the initial load... and create the project to include everything; have to be careful here if you need additional libraries (eg developing Processing projects in the NetBeans IDE, which will need the additional core.jar added to libraries)
  • set up the IDE's:
  • NetBeans:
  • use the TeamCheckout menu option
  • use the URL as below (Aptana)
  • you will be asked to create a new project to which the files will be downloaded
  • if you do, be careful not to create a new Main class (assuming you have a Java project)
  • so ideally the workflow is
  • create the initial project in the IDE
  • only keep the SRC directory
  • create the SVN structure as above
  • create the new project in the IDE based on a SVN checkout
  • Aptana:
  • open the SVN view
  • create new Repository Location (right click in the SVN window)
  • the URL will be file:///d:/svn/python
  • then back to the SVN view to check out the project into an active project (right click on the repository)
  • you will manipulate the files through the Team context menu (right click the file in the solution explorer) in the main Aptana view (not Pydev, if you are using it for Python files) - update the file, update the directory, then check it in
  • if you import it into a new project, eg AIR, you will be able to specify all the parameters again so if you have some existing project parameters (eg startup form), you will need to manually make the necessary adjustments (for AIR, change the application manifest, application.xml; also you will need to reimport the AIRAliases.js file)
  • at this point the code is checked out and available to use; remember to update/commit it to the repository
  • with AIR specifically, you shouldn't commit the icons to the repository (and others such as the .project file)

Alternatively, (at least in NetBeans), once you created the first SVN connection, you can check in a project without going through svn import. Just write the source, then right click on it and choose SubversionCommit to sent it to the repository. You can still look at the history changes between different versions - not sure how well this works in an environment with multiple users though since the original codebase is your own.

More details here. Notice that having Subversion running will show the hard drive where you have the repositories with a different icon in Windows Explorer.