# HG changeset patch # User Alexis S. L. Carvalho # Date 1161489733 10800 # Node ID f699d4eb25d97e8988afe148f984f8b416ae79bd # Parent 26285469db9bb4f4bf77ad70dcabaa7441ab5743 bash_completion: qguard diff --git a/contrib/bash_completion b/contrib/bash_completion --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -370,6 +370,43 @@ complete -o bashdefault -o default -F _h COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$guards' -- "$cur")) } +_hg_cmd_qguard() +{ + local prefix='' + + if [[ "$cur" == +* ]]; then + prefix=+ + elif [[ "$cur" == -* ]]; then + prefix=- + fi + local ncur=${cur#[-+]} + + if ! [ "$prefix" ]; then + _hg_ext_mq_patchlist qseries + return + fi + + local guards=$(_hg_ext_mq_guards) + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur")) +} + +_hg_opt_qguard() +{ + local i + for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do + if [[ ${COMP_WORDS[i]} != -* ]]; then + if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then + _hg_cmd_qguard + return 0 + fi + elif [ "${COMP_WORDS[i]}" = -- ]; then + _hg_cmd_qguard + return 0 + fi + done + return 1 +} + # hbisect _hg_cmd_bisect()