contrib/bash_completion
changeset 3486 f699d4eb25d9
parent 3485 26285469db9b
child 3992 d86ab4ba5ae6
--- a/contrib/bash_completion	Sun Oct 22 01:02:06 2006 -0300
+++ b/contrib/bash_completion	Sun Oct 22 01:02:13 2006 -0300
@@ -370,6 +370,43 @@
     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()