Coding and keeping it safe.

plugins Uncategorized

This is a Lightroom post in the sense that it’s talking about coding plugins for Lightroom. If you’re not interested in coding, you can stop right here and keep 5 minutes of your life.

I’ve lost track of the number of versions of LRB Portfolio and other plugins I have on my drive, both as code, and compiled. I literally have folders of them. Why? Well, because I’ve lost my codebase before and had to redo an update from memory, way back in between version 1.1 and 1.2. I overwrote the code with complied versions by accident. That really sucked. I called myself obscene names, but I got over it.

Talking with other developers, I heard about different ways to manage code. One of them was Subversion, but it seemed too complex for the simple codebase I have. Coda, the software I use for coding plugins and websites, has subversion built it, but it seems really geared to websites, and not good for plugins. It may well be fine, but I couldn’t get my head around it. My interest was purely academic, and I’d no reason to find a particular product.

Then something terrible happened. Somewhere between LRB Portfolio 2.3 and 2.4, an entire block of code, in the main file of the plugin, got overwritten by text. I literally have no idea how it happened. I just opened the file to edit and half of it was gone. I was able to replace the bad bits with the 2.3 code, but all the new stuff was gone. That sealed the deal for me, I had to find a way to keep my code safe always, not just when an update was launched.

After much seeking, I found a really cool piece of software called Cornerstone, from Zennaware. It does full Subversion, but I only need a tiny part of the functionality. Normally you would use a server, but I’m just using a folder on my drive. The 15 day trial seemed more like 15 days of having it open, than 15 successive days. Still they proved I needed the program, so I parted with my $60 happily.

Here’s my workflow.

I have a repository on the drive and I have a working copy checked out. I do all my edits in Coda and Cornerstone keeps track, making new copies in the background as I save. I can always step back to a previous version at any time. When I get to a point where I want to test the plugin, I commit my changes. I can choose to add text to a log file, helping figure out which previous version I might need in the future. Next I select the working copy and click on the ‘Export’ button. I’ve set this up to create a copy in the Web Galleries folder of Lightroom. While the export is happening, I restart Lightroom. The export is fast, so when Lightroom reopens, I can immediately see the changes.

What’s great about this is that the version in Web Galleries is no longer a precious commodity. I simply export the current working copy. Because Coda is working on a safe copy, with automatic backup, this working copy is used to make the compiled version of the file for beta testing. I have a script that copies the folder specified, and tags .lrwebengine to the name. It then opens this new folder and compiles the 2 .lrweb files, leaving the plugin ready for distribution. At this point, there’s a compiled version, the working copy, the copy in Web Galleries, and of course all the versions in the repository. Because of this I can then continue working on the plugin, knowing that finally, the code is safe.

8 thoughts on “Coding and keeping it safe.

  1. I'm on a PC so I use TortoiseSVN as my client, and a net based SVN repository server. Same concepts, different tools.

    My next trick is better automation for the export plugin version of some of the scripts you mentioned. Looking to setup something based upon maven 2 (or even 3, if I delay long enough). Still trying to make up my mind if it is worth the effort though.

  2. I did look at mercurial, but I'd already but some time in with Cornerstone.

    I was making backups, and but the time I lost the code, I had been working solid on it, with no backup run.

    Lesson learned.

  3. It doesn't have to be subversion at all, mercurial (aka hg) basically does the same and is so much simpler to use for local, single-user purposes.

    But still, coding some more or less serious without a proper version control or backup system? Shame on you! At least you know better know. 😉

  4. I use Beanstalk, a web-based Subversion client. Also commercial but does have a free version that allows you a single repository. What's nice about it is that you're not only saving each version of your code but doing so off-site; great if your machine should happen to die on you.

Leave a Reply

Your email address will not be published. Required fields are marked *