changeset 13509:8aea95ec128f stable

bash_completion: complete bookmarks Since bookmarks moved into core and are no longer merged with the list of tags (d012d95499f7), they don't get completed in bash_completion along with other revision specifiers. This adds a new function to provide the list of bookmarks for completion, and another, _hg_labels(), to list all tags, branches, and bookmarks. It further modifies completion for all commands where '_hg_tags; _hg_branches' was used to use '_hg_labels' instead.
author Kevin Bullock <kbullock@ringworld.org>
date Mon, 28 Feb 2011 16:45:15 -0600
parents 0396ca8015be
children d0be955f358c 0a6bca3d5273
files contrib/bash_completion
diffstat 1 files changed, 24 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/bash_completion	Mon Feb 28 17:41:40 2011 -0600
+++ b/contrib/bash_completion	Mon Feb 28 16:45:15 2011 -0600
@@ -101,6 +101,20 @@
     COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur"))
 }
 
+_hg_bookmarks()
+{
+    local bookmarks="$(_hg_cmd bookmarks -q)"
+    local IFS=$'\n'
+    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur"))
+}
+
+_hg_labels()
+{
+    _hg_tags
+    _hg_branches
+    _hg_bookmarks
+}
+
 # this is "kind of" ugly...
 _hg_count_non_option()
 {
@@ -200,12 +214,10 @@
 
     if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
 	if [ $canonical = 1 ]; then
-	    _hg_tags
-	    _hg_branches
+	    _hg_labels
 	    return 0
 	elif [[ status != "$cmd"* ]]; then
-	    _hg_tags
-	    _hg_branches
+            _hg_labels
 	    return 0
 	else
 	    return 1
@@ -220,12 +232,10 @@
 	    if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then
 		return 0
 	    fi
-	    _hg_tags
-	    _hg_branches
+	    _hg_labels
 	;;
 	manifest|update)
-	    _hg_tags
-	    _hg_branches
+	    _hg_labels
 	;;
 	pull|push|outgoing|incoming)
 	    _hg_paths
@@ -238,8 +248,7 @@
 	    _hg_status "u"
 	;;
 	merge)
-	    _hg_tags
-	    _hg_branches
+	    _hg_labels
 	;;
 	commit|record)
 	    _hg_status "mar"
@@ -378,8 +387,7 @@
 
 _hg_cmd_strip()
 {
-    _hg_tags
-    _hg_branches
+    _hg_labels
 }
 
 _hg_cmd_qcommit()
@@ -497,8 +505,7 @@
 
     case "$subcmd" in
 	good|bad)
-	    _hg_tags
-	    _hg_branches
+	    _hg_labels
 	    ;;
     esac
 
@@ -534,8 +541,7 @@
 	    ;;
     esac
 
-    _hg_tags
-    _hg_branches
+    _hg_labels
     return
 }
 
@@ -543,8 +549,7 @@
 # gpg
 _hg_cmd_sign()
 {
-    _hg_tags
-    _hg_branches
+    _hg_labels
 }
 
 
@@ -564,8 +569,7 @@
     esac
 
     # all other transplant options values and command parameters are revisions
-    _hg_tags
-    _hg_branches
+    _hg_labels
     return
 }