setlocalversion: update mercurial tag parsing
authorMike Crowe <mcrowe@zipitwireless.com>
Wed, 12 Jan 2011 05:53:52 +0000 (00:53 -0500)
committerMichal Marek <mmarek@suse.cz>
Fri, 14 Jan 2011 23:40:44 +0000 (00:40 +0100)
The tag output of hg doesn't quite match what setlocalversion currently
expects, so update it to handle the latest format.

Signed-off-by: Mike Crowe <mcrowe@zipitwireless.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/setlocalversion

index ef8729f48586d193d3926d5bd6c4d0b9c34bcb96..4d403844e137a59f53f032bc4972a35e86b2327f 100755 (executable)
@@ -86,12 +86,16 @@ scm_version()
 
        # Check for mercurial and a mercurial repo.
        if test -d .hg && hgid=`hg id 2>/dev/null`; then
-               tag=`printf '%s' "$hgid" | cut -s -d' ' -f2`
-
-               # Do we have an untagged version?
-               if [ -z "$tag" -o "$tag" = tip ]; then
-                       id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
+               # Do we have an tagged version?  If so, latesttagdistance == 1
+               if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
+                       id=`hg log -r . --template '{latesttag}'`
                        printf '%s%s' -hg "$id"
+               else
+                       tag=`printf '%s' "$hgid" | cut -d' ' -f2`
+                       if [ -z "$tag" -o "$tag" = tip ]; then
+                               id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
+                               printf '%s%s' -hg "$id"
+                       fi
                fi
 
                # Are there uncommitted changes?