Skip to content

Commit

Permalink
setlocalversion: update mercurial tag parsing
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
mike-zipit authored and michal42 committed Jan 14, 2011
1 parent 0719e1d commit 38b3439
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/setlocalversion
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 38b3439

Please sign in to comment.