setlocalversion 1012 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. # Print additional version information for non-release trees.
  3. usage() {
  4. echo "Usage: $0 [srctree]" >&2
  5. exit 1
  6. }
  7. cd "${1:-.}" || usage
  8. # Check for git and a git repo.
  9. if head=`git rev-parse --verify HEAD 2>/dev/null`; then
  10. # Do we have an untagged version?
  11. if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
  12. printf '%s%s' -g `echo "$head" | cut -c1-8`
  13. fi
  14. # Are there uncommitted changes?
  15. if git diff-index HEAD | read dummy; then
  16. printf '%s' -dirty
  17. fi
  18. # All done with git
  19. exit
  20. fi
  21. # Check for mercurial and a mercurial repo.
  22. if hgid=`hg id 2>/dev/null`; then
  23. tag=`printf '%s' "$hgid" | cut -d' ' -f2`
  24. # Do we have an untagged version?
  25. if [ -z "$tag" -o "$tag" = tip ]; then
  26. id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
  27. printf '%s%s' -hg "$id"
  28. fi
  29. # Are there uncommitted changes?
  30. # These are represented by + after the changeset id.
  31. case "$hgid" in
  32. *+|*+\ *) printf '%s' -dirty ;;
  33. esac
  34. # All done with mercurial
  35. exit
  36. fi