Damon Cortesi's blog

Musings of an entrepreneur.

Automating Subversion

| Comments

As I mentioned in the past, I’ve been working on subverting my homedir. I’ve also been putting a great deal of effort into subverting my downloads directory. I have archives that date back to 1999 (ICQ99b, anybody…) spread across multiple CD’s and archive directories collected over time. What can I say…I like history. This made subversion a good fit for this task. I wanted to centralize all my download archives and manage to keep track of their history (should I ever need an old version) and synchronize this across hosts as well. Subversion works particularly well from the history aspect as now I don’t have to have 20 versions of one program all stashed in one directory. I just have one and I checkout the appropriate revision if I need to.

However, getting my archived downloads has been somewhat of an administrative headache. I took a look at some old Kerio downloads, for example, when they were making almost 2 releases a month…and I have most of them. Renaming, copying, committing, and repeat was not sounding desirable after I had already done it several times. So what do I do, of course, but whip up a quick one-liner to do it for me. *Note - I had to enable delayed expansion for this to work. I also had to download the svn binaries (as I was doing this on Windows) and make sure I had an appropriate SSH in my path - I used TortoisePlink and just renamed it…

1
2
3
4
5
6
set SVN="D:\Program Files\TortoiseSVN\bin\svn\svn.exe"
SET OLD=kerio-pf-2.1.5-en-win.exe
B:\Storage Bin\SVN Downloads\Net>for /F "tokens=1,2,3* delims=-" %i IN ('dir /od /b R:
\Download-2004.04.27\Net\kerio-pf-4*') do %SVN% rename !OLD! %i-%j-%k-
%l && copy /Y R:\Download-2004.04.27\Net\%i-%j-%k-%l && SET OLD=%i-%j-
%k-%l && %SVN% ci -m "Update to Kerio %k"

I ran that and in about 3 minutes had 12 Kerio new versions in my repository. What that script does is loop through each Kerio 4 download in the source directory, rename the old kerio to the new kerio name (I rename so I can keep track of versions at a glance, but still keep the update history), copy the new kerio over, update the OLD variable, and then commit the changes and do it all over again!

This is going to make some of the other apps much easier to get added to the repository as well. Man, I love version control.

How appropriate this seems at the moment: I am nerdier than 87% of all people. Are you nerdier? Click here to find out!

Comments