changeset 7510:21009e85ee78

Update zsh completion to use debugcomplete -v instead of parsing help
author Brendan Cully <brendan@kublai.com>
date Thu, 04 Dec 2008 11:21:31 -0800
parents 62e5d41b0a8b
children f43a8b0ca3e8
files contrib/zsh_completion
diffstat 1 files changed, 11 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/zsh_completion	Thu Dec 04 11:21:15 2008 -0800
+++ b/contrib/zsh_completion	Thu Dec 04 11:21:31 2008 -0800
@@ -116,54 +116,18 @@
 _hg_get_commands() {
   typeset -ga _hg_cmd_list
   typeset -gA _hg_alias_list
-  local hline cmd cmdalias helpstate
-  local helpmode=$1
-
-  _call_program help hg --verbose help $helpmode 2>/dev/null | while read -A hline
-  do
-    if [ "$hline" = "list of commands:" ]
-    then
-      helpstate="commands"
-      continue
-    elif [ "$hline" = "enabled extensions:" ]
-    then
-      helpstate="extensions"
-      continue
-    elif [ "$hline" = "additional help topics:" ]
-    then
-      helpstate="topics"
-      continue
-    fi
+  local hline cmd cmdalias
 
-    if [ "$helpstate" = commands ]
-    then
-      cmd="$hline[1]"
-      case $cmd in
-        *:)
-          cmd=${cmd%:}
-          _hg_cmd_list+=($cmd)
-        ;;
-        *,)
-          cmd=${cmd%,}
-          _hg_cmd_list+=($cmd)
-          integer i=2
-          while (( i <= $#hline ))
-          do
-            cmdalias=${hline[$i]%(:|,)}
-            _hg_cmd_list+=($cmdalias)
-            _hg_alias_list+=($cmdalias $cmd)
-            (( i++ ))
-          done
-        ;;
-      esac
-    elif [ -z "$helpmode" -a "$helpstate" = extensions ]
-    then
-      cmd="$hline[1]"
-      if [ -n "$cmd" ]
-      then
-        _hg_get_commands $cmd
-      fi
-    fi
+  _call_program hg hg debugcomplete -v 2>/dev/null | while read -A hline
+  do
+    cmd=$hline[1]
+    _hg_cmd_list+=($cmd)
+
+    for cmdalias in $hline[2,-1]
+    do
+      _hg_cmd_list+=($cmdalias)
+      _hg_alias_list+=($cmdalias $cmd)
+    done
   done
 }