hg 932 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. # We want to catch any unexpected failure, and exit immediately
  3. set -e
  4. # Download helper for hg, to be called from the download wrapper script
  5. #
  6. # Call it as:
  7. # .../hg [-q] OUT_FILE REPO_URL CSET BASENAME
  8. #
  9. # Environment:
  10. # HG : the hg command to call
  11. verbose=
  12. while getopts :q OPT; do
  13. case "${OPT}" in
  14. q) verbose=-q;;
  15. \?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
  16. esac
  17. done
  18. shift $((OPTIND-1))
  19. output="${1}"
  20. repo="${2}"
  21. cset="${3}"
  22. basename="${4}"
  23. shift 4 # Get rid of our options
  24. # Caller needs to single-quote its arguments to prevent them from
  25. # being expanded a second time (in case there are spaces in them)
  26. _hg() {
  27. eval ${HG} "${@}"
  28. }
  29. _hg clone ${verbose} "${@}" --noupdate "'${repo}'" "'${basename}'"
  30. _hg archive ${verbose} --repository "'${basename}'" --type tgz \
  31. --prefix "'${basename}'" --rev "'${cset}'" \
  32. - >"${output}"