Skip to content

Commit

Permalink
kbuild: support mercurial in setlocalversion
Browse files Browse the repository at this point in the history
This represents mercurial changesets similarly to git.  For untagged
revisions, append the changeset id.  If there are uncommitted changes,
append -dirty.  For example, -hgc60016ba6237-dirty

Signed-off-by: Aron Griffis <aron@hp.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
  • Loading branch information
Aron Griffis authored and Sam Ravnborg committed Jan 28, 2008
1 parent 2f4b489 commit 3dce174
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/setlocalversion
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,27 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then
if git diff-index HEAD | read dummy; then
printf '%s' -dirty
fi

# All done with git
exit
fi

# Check for mercurial and a mercurial repo.
if hgid=`hg id 2>/dev/null`; then
tag=`printf '%s' "$hgid" | cut -d' ' -f2`

# Do we have an untagged version?
if [ -z "$tag" -o "$tag" = tip ]; then
id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
printf '%s%s' -hg "$id"
fi

# Are there uncommitted changes?
# These are represented by + after the changeset id.
case "$hgid" in
*+|*+\ *) printf '%s' -dirty ;;
esac

# All done with mercurial
exit
fi

0 comments on commit 3dce174

Please sign in to comment.