* On 16 Sep 2010, Christian Ebert wrote: > > This doesn't apply on case-insensitive filesystems - I'm using > the default HFS+ on MacOS X, which is indeed case-insensitive. > > So, no precise version header in this mail yet ;-)
Good point... wretched filesystem. I use a Mac too (but Solaris for mutt) so I should have caught this. I also addressed Cameron's observations on "exec cat" and improved performance around the double awk I was using. Although I think performance optimizations for a one-time compilation tool are sort of not worth a lot of time, why depend on awk when the shell can handle it just fine? # HG changeset patch # User David Champion <d...@uchicago.edu> # Date 1284693682 18000 # Branch HEAD # Node ID fd7c217aeaee54ac69ab6de29954ade243431008 # 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 fd7c217aeaee configure.ac --- a/configure.ac Wed Sep 15 11:47:39 2010 -0700 +++ b/configure.ac Thu Sep 16 22:21:22 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.sh` AM_INIT_AUTOMAKE(mutt, $mutt_cv_version) AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION']) diff -r 59aad6c21703 -r fd7c217aeaee version.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/version.sh Thu Sep 16 22:21:22 2010 -0500 @@ -0,0 +1,60 @@ +#!/bin/sh + +# Ensure that we have a repo here and that mercurial is installed. If +# not, just cat the VERSION file; it contains the latest release number. +{ [ -d .hg ] && hg >/dev/null 2>&1; } || exec cat VERSION + +# This is a mercurial repo and we have the hg command. + +# Get essential properties of the current working copy +set -- $(hg parents --template='{rev} {node|short}\n') +rev="$1" +node="$2" + +# translate release tags into ##.##.## notation +cleantag () { + case "$1" in + mutt-*-rel) echo "$1" | sed -e 's/mutt-//' -e 's/-rel//' | tr - . ;; + *) echo "$1" ;; + esac +} + +getdistance_old () { + # fudge it + set -- $(hg tags | sort -n +1 | egrep 'mutt-.*rel' | tail -1 | cut -d: -f1) + latesttag="$1" + latestrev="$2" + distance=$(($rev - $latestrev)) + echo $latesttag $distance +} + +getdistance_new () { + hg parents --template='{latesttag} {latesttagdistance}\n' +} + + +# latesttag appeared in hg 1.4. Test for it. +[ "$(hg log -r . --template='{latesttag}')" = '' ] && +set -- $(getdistance_old) || +set -- $(getdistance_new) + +tag=$(cleantag "$1") +dist=$2 + +if [ $dist -eq 0 ]; then + dist= +else + dist="+$dist" +fi + +# if we have mq patches applied, mention it +qparent=$(hg log -r qparent --template='{rev}\n' 2>/dev/null || echo $rev) +qdelta=$(expr $rev - $qparent) +if [ $qdelta -eq 0 ]; then + qdist="" +else + qdist=",mq+$qdelta" +fi + +echo "$tag$dist$qdist ($node)" +exit 0 -- David Champion * d...@uchicago.edu * IT Services * University of Chicago