October 26, 2007

Version Control for your Scripts

Filed under: General — Marcus Tettmar @ 1:35 pm

If you work regularly on large macro files you should consider using a version control system. Remember that time when you made a few small changes to that 2000 line macro and it stopped working and you spent ages trying to figure out what you did and get it working again, losing a lot of hair in the process? Ok, so you had a backup right? But what if you needed to get back to a version from before the backup – and quick?

Macro Scheduler’s advanced editor gives you a “Backup on Save” option. This keeps the last three copies of each script each time you save. If you look in the script’s folder you will see a .001, .002 and .003 file as well as the main .scp file.

But you may want more control than this. You might want to look at the code as it was three months ago. And if you distribute compiled macros to clients you may need complete version control. With a version control system you can create branches from your main code. Let’s say you create a utility which you sell to your clients. When you release version 2.0 you might still want to support version 1.0. If a customer using version 1.0 finds a bug you need to fix that bug in the version 1.0 code without them having to upgrade to 2.0. Or you may create customisations for different clients. A client may need some changes but you don’t want those changes in the main code base. Or perhaps you have more than one person working on your script files and you need a way to keep your changes in sync.

With a Version Control System you “check” files in and out of the “repository”. So when you’ve done making changes to a script you can “check” it in. The VCS adds this change as a new version. Later you can check it out. Normally you’d work on the “HEAD” – the most up to date version. But if you need to go back to a previous version you can choose to check out a different version. You can see all the versions in the repository. When you check a file in you would normally write a short note as you do so, so you know what changes you made. So by using a version control system you have a complete track of all the changes you ever made, and you can get back to a previous version easily and safely.

This is when you need a version control system. We use TortoiseSVN here to manage the Macro Scheduler source code. You could use it for your Macro Scheduler script files too. In fact you can use version control for pretty much any kind of files you work on regularly.

You can find our more about TortoiseSVN here: http://tortoisesvn.net

TortoiseSVN integrates directly with Windows Explorer. It’s really easy to check files in and out just by using Windows Explorer. The help file that comes with TortoiseSVN is helpful with a good introduction if you’re a newbie, and provides some tips on how to set up your repository.

If you’re new to version control here’s a really nice visual guide:
http://betterexplained.com/articles/a-visual-guide-to-version-control/

For those of you who work regularly on large script files for multiple clients – and I know a number of you do – you should think seriously about using source control.