May 4th 2007 11:12 am

Easily Syncing Remote Files in Komodo With Unison

In my day to day work, I edit code on one machine, then move the new code to a different machine to build packages for installation and testing. Until recently I was doing one of two things:
1) Mounting an SMB/NFS share and editing the remote files directly
2) Using rsync to copy files back and forth from my dev machine to my build machine

Both methods “worked” but had their downsides. With the remote SMB, I had to have network access if I wanted to work. Since I was also directly editing the source, I only had one copy and if I hadn’t checked in to CVS yet, and something went wrong, I could be screwed. I couldn’t work on anything if I was not connected to the corporate network here at work (ether physically, or via ssh tunnel).
rsync worked alright, but the syncing is one way, so I had to do some weird double syncing to make sure all the changes were propagated. I had to be really careful with edits because if two files were changed in both locations, I would again screwed - no merging. One side of the changes would always be lost. The other downside to this was that if the system times on each machine were not *exactly* the same, rsync would sync files that were not edited, which changed the file’s timestamp, which then caused CVS to see them as edited. It was a mess.

A couple of weeks ago I found Unison:

Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.

With Unison, you simply set up the source and destination directories, which can be local or remote and then tell it to sync. There are optional ways of connecting to remote directories, I personally use ssh, which then uses an ssh tunnel I have set up in my ssh_config file.

This worked great, but I soon grew a little tired of editing files in Komodo, flipping to my Unison window, syncing, then flipping back to Komodo. Then it hit me, “why don’t i just set this sync up as a toolbox item?”. Unison has a command line interface, so after a quick read of the ‘-help’ output, I created a toolbox item with unison -batch -auto; (read the ‘-help’ to customize your sync with your own preferences), then set up a keyboard shortcut CTRL+ALT+S to trigger it. Now I can happily edit my code on my laptop and sync with a quick flick of the fingers.

NOTE: I have this set up in Linux, but since both Komodo and Unison are available for Windows, it should be trivial to accomplish the same in that environment

No Comments yet »

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.

« An easier way to do simple matches with PHP | The One Line Cross-Browser Ajax Request Object »