comparison contrib/zsh_completion @ 3534:811e6c95485c

zsh: use standard tags where possible
author Brendan Cully <brendan@kublai.com>
date Thu, 26 Oct 2006 09:44:03 -0700
parents fe9c1e886b5e
children 3dbec3f6d3a2
comparison
equal deleted inserted replaced
3533:891c8d20f80f 3534:811e6c95485c
3 # Zsh completion script for mercurial. Rename this file to _hg and copy 3 # Zsh completion script for mercurial. Rename this file to _hg and copy
4 # it into your zsh function path (/usr/share/zsh/site-functions for 4 # it into your zsh function path (/usr/share/zsh/site-functions for
5 # instance) 5 # instance)
6 # 6 #
7 # Copyright (C) 2005 Steve Borho 7 # Copyright (C) 2005 Steve Borho
8 # Copyright (C) 2006 Brendan Cully 8 # Copyright (C) 2006 Brendan Cully <brendan@kublai.com>
9 # 9 #
10 # This is free software; you can redistribute it and/or modify it under 10 # This is free software; you can redistribute it and/or modify it under
11 # the terms of the GNU General Public License as published by the Free 11 # the terms of the GNU General Public License as published by the Free
12 # Software Foundation; either version 2 of the License, or (at your 12 # Software Foundation; either version 2 of the License, or (at your
13 # option) any later version. 13 # option) any later version.
14 # 14 #
15 15
16 local curcontext="$curcontext" state line 16 local curcontext="$curcontext" state line
17 local repos newFiles addedFiles commitMessage
18 typeset -A _hg_cmd_globals 17 typeset -A _hg_cmd_globals
19 18
20 _hg() { 19 _hg() {
21 local cmd 20 local cmd
22 integer i=2 21 integer i=2
113 done 112 done
114 } 113 }
115 114
116 _hg_commands() { 115 _hg_commands() {
117 (( $#_hg_cmd_list )) || _hg_get_commands 116 (( $#_hg_cmd_list )) || _hg_get_commands
118 _describe -t hg-commands 'mercurial command' _hg_cmd_list 117 _describe -t commands 'mercurial command' _hg_cmd_list
119 } 118 }
120 119
121 _hg_tags() { 120 _hg_tags() {
122 typeset -a tags 121 typeset -a tags
123 local tag rev 122 local tag rev
124 123
125 _hg_cmd tags 2> /dev/null | while read tag rev 124 _hg_cmd tags 2> /dev/null | while read tag rev
126 do 125 do
127 tags+=($tag) 126 tags+=($tag)
128 done 127 done
129 (( $#tags )) && _describe -t hg-tags 'tags' tags 128 (( $#tags )) && _describe -t tags 'tags' tags
130 } 129 }
131 130
132 _hg_status() { 131 _hg_status() {
133 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 .)"}) 132 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 .)"})
134 } 133 }
135 134
136 _hg_unknown() { 135 _hg_unknown() {
137 typeset -a status_files 136 typeset -a status_files
138 _hg_status u 137 _hg_status u
139 (( $#status_files )) && _describe -t hg-unknown-files 'unknown files' status_files 138 (( $#status_files )) && _describe -t files 'unknown files' status_files
140 } 139 }
141 140
142 _hg_missing() { 141 _hg_missing() {
143 typeset -a status_files 142 typeset -a status_files
144 _hg_status d 143 _hg_status d
145 (( $#status_files )) && _describe -t hg-missing-files 'missing files' status_files 144 (( $#status_files )) && _describe -t files 'missing files' status_files
146 } 145 }
147 146
148 _hg_addremove() { 147 _hg_addremove() {
149 _alternative "unknown files:unknown files:_hg_unknown" \ 148 _alternative 'files:unknown files:_hg_unknown' \
150 "missing files:missing files:_hg_missing" 149 'files:missing files:_hg_missing'
151 } 150 }
152 151
153 _hg_paths() { 152 _hg_paths() {
154 typeset -a paths pnames 153 typeset -a paths pnames
155 _hg_cmd paths 2> /dev/null | while read -A pnames 154 _hg_cmd paths 2> /dev/null | while read -A pnames
156 do 155 do
157 paths+=($pnames[1]) 156 paths+=($pnames[1])
158 done 157 done
159 (( $#paths )) && _describe -t hg-paths 'repository aliases' paths 158 (( $#paths )) && _describe -t urls 'repository aliases' paths
160 } 159 }
161 160
162 _hg_remote() { 161 _hg_remote() {
163 _alternative 'repository aliases:repository aliases:_hg_paths' \ 162 _alternative 'urls:repository alias:_hg_paths' \
164 'directory:directory:_files -/' 163 'directories:directory:_files -/'
165 } 164 }
166 165
167 # Common options 166 # Common options
168 _hg_global_opts=( 167 _hg_global_opts=(
169 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/' 168 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'