Bazaar: push-and-update plugin with putty’s plink

I recently came across the push-and-update plugin for Bazaar (a version control system). The plugin is useful for anyone pushing changes to a remote server and wanting to keep the remote working tree up to date as well.

According to Bazaar docs:

“When you push a branch to a remote system, a working tree will not be created. If one is already present the files will not be updated. The branch information will be updated and the working tree will be marked as out-of-date. Updating a working tree remotely is difficult, as there may be uncommitted changes or the update may cause content conflicts that are difficult to deal with remotely.”

The push-and-update plugin solves the problem by carrying out the push as normal but then SSHing into the account and carrying out the ‘bzr update’ command to update the working tree as well. The only problem with running this on Windows is that the plugin assumes you have the ssh command available. So if you’d like to use putty’s plink instead, open the push_and_update.py file and change this line:

cmd = ['ssh', user+host+port, remote_bzr, 'update', path]

to

cmd = ['c:\path\to\plink.exe', user+host+port, remote_bzr, 'update', path]

To avoid editing the file completely, you can download and rename plink.exe to ssh.exe and place it in one of the directories listed in your system PATH variable. (Note: the Bazaar client may throw errors if you leave plink.exe in a directory listed in your PATH variable – at least it did for me – so make sure it’s renamed if you experience a similar problem.)

This appears to be a known bug.