[PATCH] Include extra information in mutt version string for developer builds
# HG changeset patch
# User David Champion <dgc@xxxxxxxxxxxx>
# Date 1284612294 18000
# Branch HEAD
# Node ID 1c6c5a4e168219a6e26ba6143cabe9f7564dfcac
# Parent 59aad6c21703484a9a298536efd4d971039d0a61
Include extra information in mutt version string for developer builds.
When a build is based on an hg clone, include extra information about
the changeset node, distance from a tagged release, and mq applied patch
count.
For example, after this patch is applied my mutt build identifies itself
(in mutt -v and in <show-version>) as:
Mutt 1.5.21+26,mq+22 (7edc2073390d) (2010-09-15)
I have applied 26 changesets applied since 1.5.21 was tagged, 22 of
which are in my mq patch series. A 1.5.21 release build that is not
mercurial-based would still appear simply as "1.5.21".
diff -r 59aad6c21703 -r 1c6c5a4e1682 configure.ac
--- a/configure.ac Wed Sep 15 11:47:39 2010 -0700
+++ b/configure.ac Wed Sep 15 23:44:54 2010 -0500
@@ -7,7 +7,7 @@
AC_INIT([mutt.h])
AM_CONFIG_HEADER([config.h])
-mutt_cv_version=`cat $srcdir/VERSION`
+mutt_cv_version=`./version`
AM_INIT_AUTOMAKE(mutt, $mutt_cv_version)
AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION'])
diff -r 59aad6c21703 -r 1c6c5a4e1682 version
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/version Wed Sep 15 23:44:54 2010 -0500
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+[ -d .hg ] || { cat VERSION; exit 0; }
+hg >/dev/null 2>&1 || { cat VERSION; exit 0; }
+
+# This is a mercurial repo and we have the hg command
+
+cur=$(hg id -n -r .)
+qparent=$(hg log -r qparent --template='{rev}\n' 2>/dev/null || echo $cur)
+qdelta=$(expr $cur - $qparent)
+
+# The while loop is wonky but some shells (bash) have trouble with piping
+# into "read", as with "echo 1 2 | read one two".
+hg parents --template='{latesttag} {latesttagdistance} {node|short}\n' | while
read tag dist node; do
+ # first translate release tags into ##.##.## notation
+ case "$tag" in
+ mutt-*-rel) tag=`echo $tag | sed -e 's/mutt-//' -e
's/-rel//' | tr - .`;;
+ esac
+
+ # if we have nonzero distance from the latest tag, include that info
+ if [ $dist -eq 0 ]; then
+ dist=""
+ else
+ dist="+$dist"
+ fi
+
+ # if we have mq patches applied, mention it
+ if [ $qdelta -eq 0 ]; then
+ qdist=""
+ else
+ qdist=",mq+$qdelta"
+ fi
+
+ echo "$tag$dist$qdist ($node)"
+ exit 0
+done