Skip to content

Commit 3dce174

Browse files
Aron Griffissravnborg
authored andcommitted
kbuild: support mercurial in setlocalversion
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>
1 parent 2f4b489 commit 3dce174

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎scripts/setlocalversion‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,27 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then
1919
if git diff-index HEAD | read dummy; then
2020
printf '%s' -dirty
2121
fi
22+
23+
# All done with git
24+
exit
25+
fi
26+
27+
# Check for mercurial and a mercurial repo.
28+
if hgid=`hg id 2>/dev/null`; then
29+
tag=`printf '%s' "$hgid" | cut -d' ' -f2`
30+
31+
# Do we have an untagged version?
32+
if [ -z "$tag" -o "$tag" = tip ]; then
33+
id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
34+
printf '%s%s' -hg "$id"
35+
fi
36+
37+
# Are there uncommitted changes?
38+
# These are represented by + after the changeset id.
39+
case "$hgid" in
40+
*+|*+\ *) printf '%s' -dirty ;;
41+
esac
42+
43+
# All done with mercurial
44+
exit
2245
fi

0 commit comments

Comments
 (0)