##// END OF EJS Templates
zsh completion: basic merge support
Brendan Cully -
r8983:0701044a default
parent child Browse files
Show More
@@ -139,7 +139,7 b' typeset -A _hg_cmd_globals'
139 typeset -gA _hg_alias_list
139 typeset -gA _hg_alias_list
140 local hline cmd cmdalias
140 local hline cmd cmdalias
141
141
142 _call_program hg hg debugcomplete -v 2>/dev/null | while read -A hline
142 _call_program hg hg debugcomplete -v | while read -A hline
143 do
143 do
144 cmd=$hline[1]
144 cmd=$hline[1]
145 _hg_cmd_list+=($cmd)
145 _hg_cmd_list+=($cmd)
@@ -166,13 +166,26 b' typeset -A _hg_cmd_globals'
166 typeset -a tags
166 typeset -a tags
167 local tag rev
167 local tag rev
168
168
169 _hg_cmd tags 2> /dev/null | while read tag
169 _hg_cmd tags | while read tag
170 do
170 do
171 tags+=(${tag/ # [0-9]#:*})
171 tags+=(${tag/ # [0-9]#:*})
172 done
172 done
173 (( $#tags )) && _describe -t tags 'tags' tags
173 (( $#tags )) && _describe -t tags 'tags' tags
174 }
174 }
175
175
176 # likely merge candidates
177 _hg_mergerevs() {
178 typeset -a heads
179 local myrev
180
181 heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
182 # exclude own revision
183 myrev=$(_hg_cmd log -r . --template '{rev}\\n')
184 heads=(${heads:#$myrev})
185
186 (( $#heads )) && _describe -t heads 'heads' heads
187 }
188
176 _hg_files() {
189 _hg_files() {
177 if [[ -n "$_hg_root" ]]
190 if [[ -n "$_hg_root" ]]
178 then
191 then
@@ -192,7 +205,7 b' typeset -A _hg_cmd_globals'
192
205
193 _hg_status() {
206 _hg_status() {
194 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
207 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
195 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX 2>/dev/null)"})
208 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
196 }
209 }
197
210
198 _hg_unknown() {
211 _hg_unknown() {
@@ -214,11 +227,11 b' typeset -A _hg_cmd_globals'
214 }
227 }
215
228
216 _hg_resolve() {
229 _hg_resolve() {
217 local rstate rpah
230 local rstate rpath
218
231
219 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
232 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
220
233
221 _hg_cmd resolve -l ./$PREFIX 2> /dev/null | while read rstate rpath
234 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
222 do
235 do
223 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
236 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
224 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
237 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
@@ -262,7 +275,7 b' typeset -A _hg_cmd_globals'
262 compset -P '*/'
275 compset -P '*/'
263 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
276 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
264 then
277 then
265 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/})
278 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
266 _store_cache "$cacheid" remdirs
279 _store_cache "$cacheid" remdirs
267 fi
280 fi
268 _describe -t directories 'remote directory' remdirs -S/
281 _describe -t directories 'remote directory' remdirs -S/
@@ -300,7 +313,7 b' typeset -A _hg_cmd_globals'
300
313
301 _hg_paths() {
314 _hg_paths() {
302 typeset -a paths pnames
315 typeset -a paths pnames
303 _hg_cmd paths 2> /dev/null | while read -A pnames
316 _hg_cmd paths | while read -A pnames
304 do
317 do
305 paths+=($pnames[1])
318 paths+=($pnames[1])
306 done
319 done
@@ -365,7 +378,7 b' typeset -A _hg_cmd_globals'
365
378
366 _hg_cmd() {
379 _hg_cmd() {
367 _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \
380 _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \
368 "$_hg_cmd_globals[@]" "$@"
381 "$_hg_cmd_globals[@]" "$@" 2> /dev/null
369 }
382 }
370
383
371 _hg_cmd_add() {
384 _hg_cmd_add() {
@@ -565,6 +578,14 b' typeset -A _hg_cmd_globals'
565 ':revision:_hg_tags'
578 ':revision:_hg_tags'
566 }
579 }
567
580
581 _hg_cmd_merge() {
582 _arguments -s -w : $_hg_global_opts \
583 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
584 '(--rev -r)'{-r,--rev}'[revision to merge]:revision:_hg_tags' \
585 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
586 ':revision:_hg_mergerevs'
587 }
588
568 _hg_cmd_outgoing() {
589 _hg_cmd_outgoing() {
569 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
590 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
570 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
591 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
@@ -735,13 +756,13 b' typeset -A _hg_cmd_globals'
735 # MQ
756 # MQ
736 _hg_qseries() {
757 _hg_qseries() {
737 typeset -a patches
758 typeset -a patches
738 patches=(${(f)"$(_hg_cmd qseries 2>/dev/null)"})
759 patches=(${(f)"$(_hg_cmd qseries)"})
739 (( $#patches )) && _describe -t hg-patches 'patches' patches
760 (( $#patches )) && _describe -t hg-patches 'patches' patches
740 }
761 }
741
762
742 _hg_qapplied() {
763 _hg_qapplied() {
743 typeset -a patches
764 typeset -a patches
744 patches=(${(f)"$(_hg_cmd qapplied 2>/dev/null)"})
765 patches=(${(f)"$(_hg_cmd qapplied)"})
745 if (( $#patches ))
766 if (( $#patches ))
746 then
767 then
747 patches+=(qbase qtip)
768 patches+=(qbase qtip)
@@ -751,15 +772,15 b' typeset -A _hg_cmd_globals'
751
772
752 _hg_qunapplied() {
773 _hg_qunapplied() {
753 typeset -a patches
774 typeset -a patches
754 patches=(${(f)"$(_hg_cmd qunapplied 2>/dev/null)"})
775 patches=(${(f)"$(_hg_cmd qunapplied)"})
755 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
776 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
756 }
777 }
757
778
758 # unapplied, including guarded patches
779 # unapplied, including guarded patches
759 _hg_qdeletable() {
780 _hg_qdeletable() {
760 typeset -a unapplied
781 typeset -a unapplied
761 unapplied=(${(f)"$(_hg_cmd qseries 2>/dev/null)"})
782 unapplied=(${(f)"$(_hg_cmd qseries)"})
762 for p in $(_hg_cmd qapplied 2>/dev/null)
783 for p in $(_hg_cmd qapplied)
763 do
784 do
764 unapplied=(${unapplied:#$p})
785 unapplied=(${unapplied:#$p})
765 done
786 done
@@ -771,7 +792,7 b' typeset -A _hg_cmd_globals'
771 typeset -a guards
792 typeset -a guards
772 local guard
793 local guard
773 compset -P "+|-"
794 compset -P "+|-"
774 _hg_cmd qselect -s 2>/dev/null | while read guard
795 _hg_cmd qselect -s | while read guard
775 do
796 do
776 guards+=(${guard#(+|-)})
797 guards+=(${guard#(+|-)})
777 done
798 done
General Comments 0
You need to be logged in to leave comments. Login now