diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d0951df..d7dd169 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -620,6 +620,11 @@ extract_git() { download_hg() { local netfile=$1 + local fragment=${netfile#*#} + if [[ $fragment = "$netfile" ]]; then + unset fragment + fi + local dir=$(get_filepath "$netfile") [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")" @@ -629,9 +634,22 @@ download_hg() { url=${url##*hg+} url=${url%%#*} + local ref + if [[ -n $fragment ]]; then + case ${fragment%%=*} in + branch|revision|tag) + ref=('-r' "${fragment##*=}") + ;; + *) + error "$(gettext "Unrecognized reference: %s")" "${fragment}" + plain "$(gettext "Aborting...")" + exit 1 + esac + fi + if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg" - if ! hg clone -U "$url" "$dir"; then + if ! hg clone -U "${ref[@]}" "$url" "$dir"; then error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg" plain "$(gettext "Aborting...")" exit 1 @@ -639,7 +657,7 @@ download_hg() { elif (( ! HOLDVER )); then msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg" cd_safe "$dir" - if ! hg pull; then + if ! hg pull "${ref[@]}"; then # only warn on failure to allow offline builds warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg" fi