From: Aron Griffis Date: Wed, 28 Nov 2007 21:55:44 +0000 (-0500) Subject: kbuild: support mercurial in setlocalversion X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3dce174cfcba11026b028d33bed0438b80e37124;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Sam Ravnborg --- diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 82e4993f0a73..a80d6ea8a5bf 100644 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -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