Support branch names in contrib/bash_completion
authorSteve Losh <steve@stevelosh.com>
Wed, 03 Jun 2009 22:58:43 -0400
changeset 8719 b5e9ed63913b
parent 8718 3463b28681ee
child 8720 da1b93583855
Support branch names in contrib/bash_completion Anywhere a revision is needed a branch name can be used to specify the tip of that branch, so branch names should be tab completed.
contrib/bash_completion
--- a/contrib/bash_completion	Wed Jun 03 22:54:53 2009 -0400
+++ b/contrib/bash_completion	Wed Jun 03 22:58:43 2009 -0400
@@ -89,6 +89,13 @@
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
 }
 
+_hg_branches()
+{
+    local branches="$("$hg" branches -q 2>/dev/null)"
+    local IFS=$'\n'
+    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur"))
+}
+
 # this is "kind of" ugly...
 _hg_count_non_option()
 {
@@ -189,9 +196,11 @@
     if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
 	if [ $canonical = 1 ]; then
 	    _hg_tags
+	    _hg_branches
 	    return 0
 	elif [[ status != "$cmd"* ]]; then
 	    _hg_tags
+	    _hg_branches
 	    return 0
 	else
 	    return 1
@@ -207,9 +216,11 @@
 		return 0
 	    fi
 	    _hg_tags
+	    _hg_branches
 	;;
 	manifest|update)
 	    _hg_tags
+	    _hg_branches
 	;;
 	pull|push|outgoing|incoming)
 	    _hg_paths
@@ -223,6 +234,7 @@
 	;;
 	merge)
 	    _hg_tags
+	    _hg_branches
 	;;
 	commit)
 	    _hg_status "mar"
@@ -338,6 +350,7 @@
 _hg_cmd_strip()
 {
     _hg_tags
+    _hg_branches
 }
 
 _hg_cmd_qcommit()
@@ -446,6 +459,7 @@
     case "$subcmd" in
 	good|bad)
 	    _hg_tags
+	    _hg_branches
 	    ;;
     esac
 
@@ -482,6 +496,7 @@
     esac
 
     _hg_tags
+    _hg_branches
     return
 }
 
@@ -490,6 +505,7 @@
 _hg_cmd_sign()
 {
     _hg_tags
+    _hg_branches
 }
 
 
@@ -510,6 +526,7 @@
 
     # all other transplant options values and command parameters are revisions
     _hg_tags
+    _hg_branches
     return
 }