Oct 18, 2007

Using Subversion Branches and Externals

If you have been following my twitter feeds lately you already know that I've been trying to figure out some subversion stuff for a current project I have to come up with some process around using subversion. Well, I'm a real newbie at this and Google was only slightly helpful. Well, I think I learned what I set out to learn and I thought I would post my findings here.

References:
http://blog.kowalczyk.info/archives/2006/06/06/short-tutorial-on-svn-propset-for-svnexternals-property/
http://svnbook.red-bean.com/en/1.1/ch07s04.html
http://svnbook.red-bean.com/en/1.1/ch04.html

Creating a Branch:
syntax: svn copy source target
example to copy from trunk to current directory:
svn copy svn://localhost/trunk/DW/RIM/RIM/Stored/MY_STORED_PROC.sql .

Merging changes:
syntax: svn merge svn://original_path_to_file -r[Original Version]:[Version to Merge] /new_file_path
example:
svn merge svn://localhost/branches/DW/RIM_1.4/MY_STORED_PROC.sql -r1:2 ./MY_STORED_PROC.sql

Creating Externals:
Notes:
Externals can only be created on directories, not individual files.
Externals provide an alias to a directory within subversion
Creating externals involves setting a property on a subversion directory.
To create a directory that has subdirectories that are externals:
1. Create a file with the alias definitions. The contents of the files should be like this:
alias_directory_name path_in_subversion
for example
$ cat alias_def.txt
stored_proc svn://localhost/trunk/DW/RIM/RIM/Stored

You can create multiple subdirectories with multiple entries. For example
$cat alias_def.txt
stored_proc svn://localhost/trunk/DW/RIM/RIM/Stored
tables svn://localhost/trunk/DW/RIM/RIM/Tables

Once the definition file has been created, it can be applied using the svn propset command to a working subversion directory using the following commands:
svn propset svn:externals . -F alias_def.txt
svn update

These commands will create the directories "stored_proc" and "tables" with the appropriate contents as defined in alias_dev.txt in the current working subversion directory.

No comments: