Mercurial > hg
changeset 7469:e63843793f01
Merge with crew-stable
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 22:22:14 +0100 |
parents | 0d1c5e638d07 (diff) 3e5db4228f8f (current diff) |
children | 1d58c0491d5e |
files | |
diffstat | 1 files changed, 48 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/zsh_completion Tue Nov 18 21:46:01 2008 -0600 +++ b/contrib/zsh_completion Fri Dec 05 22:22:14 2008 +0100 @@ -4,14 +4,13 @@ # it into your zsh function path (/usr/share/zsh/site-functions for # instance) # -# Copyright (C) 2005 Steve Borho +# Copyright (C) 2005-6 Steve Borho # Copyright (C) 2006-8 Brendan Cully <brendan@kublai.com> # # This is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your # option) any later version. -# emulate -LR zsh setopt extendedglob @@ -117,28 +116,54 @@ _hg_get_commands() { typeset -ga _hg_cmd_list typeset -gA _hg_alias_list - local hline cmd cmdalias - _call_program help hg --verbose help | while read -A hline + local hline cmd cmdalias helpstate + local helpmode=$1 + + _call_program help hg --verbose help $helpmode 2>/dev/null | while read -A hline do - 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 + 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 + + 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 done }