]> granicus.if.org Git - mutt/commitdiff
Extra information in mutt version string, redux.
authorDavid Champion <dgc@bikeshed.us>
Mon, 7 Mar 2011 16:17:59 +0000 (10:17 -0600)
committerDavid Champion <dgc@bikeshed.us>
Mon, 7 Mar 2011 16:17:59 +0000 (10:17 -0600)
Restores [f1b4d1d17200] functionality with a slight change to keep
'make dist' working (see backout in [6b38124a5b81]).

Automake is too much voodoo for me at this time, so I let it keep
VERSION. mutt.h defined MUTT_VERSION as VERSION and the code used that,
so I removed MUTT_VERSION from mutt.h and put it into config.h via
configure.ac.  A couple of tweaks were needed elsewhere.  This restores
the fancy-versioning feature within mutt and keeps 'make dist' happy.

configure.ac
dotlock.c
mutt.h
version.sh [new file with mode: 0644]

index 5a8c7f0eccceb4287c7e9a5abee1453e6e267d6c..bbcf5f8e596050aba9137953374a7a315100c9d9 100644 (file)
@@ -11,6 +11,9 @@ mutt_cv_version=`cat $srcdir/VERSION`
 AM_INIT_AUTOMAKE(mutt, $mutt_cv_version)
 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION'])
 
+MUTT_VERSION=`sh ./version.sh`
+AC_DEFINE_UNQUOTED(MUTT_VERSION,"$MUTT_VERSION", [Full textual version string.])
+
 AC_GNU_SOURCE
 
 ALL_LINGUAS="de eu ru it es uk fr pl nl cs id sk ko el zh_TW zh_CN pt_BR eo gl sv da lt tr ja hu et ca bg ga"
index d9a05aaf867405fcd90ec3c59e8c08822e6684d8..5bf03480a60833ba2f2c5b98ac35281fbba2459c 100644 (file)
--- a/dotlock.c
+++ b/dotlock.c
@@ -339,7 +339,7 @@ END_PRIVILEGED (void)
 static void 
 usage (const char *av0)
 {
-  fprintf (stderr, "dotlock [Mutt %s (%s)]\n", VERSION, ReleaseDate);
+  fprintf (stderr, "dotlock [Mutt %s (%s)]\n", MUTT_VERSION, ReleaseDate);
   fprintf (stderr, "usage: %s [-t|-f|-u|-d] [-p] [-r <retries>] file\n",
          av0);
 
diff --git a/mutt.h b/mutt.h
index f7a024e54a556a1329d4bdef18a868747e9f8d90..45635173b7cebf8b761d8b25712538da65e8513d 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -66,8 +66,6 @@
 # define MB_LEN_MAX 16
 #endif
 
-#define MUTT_VERSION (VERSION)
-
 /* nifty trick I stole from ELM 2.5alpha. */
 #ifdef MAIN_C
 #define WHERE 
diff --git a/version.sh b/version.sh
new file mode 100644 (file)
index 0000000..cd902bd
--- /dev/null
@@ -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=`expr $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