Mercurial version check

At work, I’ve installed Mercurial on a range of UNIX systems, including Linux, FreeBSD and Solaris hosts. Some times it is necessary to make sure which version of Mercurial is installed on one or more of these systems.

For example, after an important bugfix in the Mercurial Crew Repository, and running tests on my laptop, I update the Mercurial installation on several UNIX systems in a row. Since the update may take a while, and I may be interrupted for some other task in the process, I wanted an easy way to check the version of Mercurial on many hosts at once.

Here’s a small SSH-based script I use to do this:

#!/bin/sh

if test "${CHECKHOSTS}" ; then
    CHECKHOSTS='localhost fingon finrod eomer rohan moria'
fi

for name in ${CHECKHOSTS} ; do
     echo "${name}" \\
       $(ssh "${name}" \\
         'hg version | grep version | \\
          sed -e "s/.*version //" -e "s/)//"')
done 2>&1 | awk '{printf "%-20s %s\\n",$1,$2}'

A typical batch of output from the script looks like this:

localhost            14e67cd9a465
fingon               14e67cd9a465
finrod               14e67cd9a465
eomer                14e67cd9a465
rohan                14e67cd9a465
moria                14e67cd9a465

So, with a glance, I can see that all my test machines run exactly the
same version of Mercurial :-)