comparison contrib/zsh_completion @ 39444:45d12c49c3f3

zsh_completion: complete shelve and unshelve Differential Revision: https://phab.mercurial-scm.org/D4428
author Anton Shestakov <av6@dwimlabs.net>
date Wed, 22 Aug 2018 09:02:07 +0800
parents 2815e0db4c54
children 5f06c21d37de
comparison
equal deleted inserted replaced
39443:2815e0db4c54 39444:45d12c49c3f3
283 _describe -t internal_tools 'internal merge tools' _hg_internal_merge_tools 283 _describe -t internal_tools 'internal merge tools' _hg_internal_merge_tools
284 external_tools=(${(f)"$(_hg_cmd showconfig merge-tools | cut -d . -f 2)"}) 284 external_tools=(${(f)"$(_hg_cmd showconfig merge-tools | cut -d . -f 2)"})
285 (( $#external_tools )) && _describe -t external_tools 'external merge tools' external_tools 285 (( $#external_tools )) && _describe -t external_tools 'external merge tools' external_tools
286 } 286 }
287 287
288 _hg_shelves() {
289 shelves=("${(f)$(_hg_cmd shelve -ql)}")
290 (( $#shelves )) && _describe -t shelves 'shelves' shelves
291 }
292
288 _hg_addremove() { 293 _hg_addremove() {
289 _alternative 'files:unknown files:_hg_unknown' \ 294 _alternative 'files:unknown files:_hg_unknown' \
290 'files:missing files:_hg_missing' 295 'files:missing files:_hg_missing'
291 } 296 }
292 297
1257 '--all[purge ignored files too]' \ 1262 '--all[purge ignored files too]' \
1258 '(--print -p)'{-p,--print}'[print filenames instead of deleting them]' \ 1263 '(--print -p)'{-p,--print}'[print filenames instead of deleting them]' \
1259 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs (implies -p/--print)]' 1264 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs (implies -p/--print)]'
1260 } 1265 }
1261 1266
1267 # Shelve
1268 _hg_cmd_shelve() {
1269 local context state state_descr line ret=1
1270 typeset -A opt_args
1271
1272 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
1273 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before shelving]' \
1274 '(--unknown -u)'{-u,--unknown}'[store unknown files in the shelve]' \
1275 '(--name -n :)--cleanup[delete all shelved changes]' \
1276 '--date=[shelve with the specified commit date]:date' \
1277 '(--delete -d)'{-d,--delete}'[delete the named shelved change(s)]' \
1278 '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
1279 '(--list -l)'{-l,--list}'[list current shelves]' \
1280 '(--message -m)'{-m+,--message=}'[use text as shelve message]:text' \
1281 '(--name -n)'{-n+,--name=}'[use the given name for the shelved commit]:name' \
1282 '(--patch -p)'{-p,--patch}'[output patches for changes]' \
1283 '(--interactive -i)'{-i,--interactive}'[interactive mode, only works while creating a shelve]' \
1284 '--stat[output diffstat-style summary of changes]' \
1285 '*:file:->shelve_files' && ret=0
1286
1287 if [[ $state == 'shelve_files' ]]
1288 then
1289 if [[ -n ${opt_args[(I)-d|--delete|-l|--list|-p|--patch|--stat]} ]]
1290 then
1291 _hg_shelves && ret=0
1292 else
1293 typeset -a status_files
1294 _hg_status mard
1295 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0
1296 fi
1297 fi
1298
1299 return ret
1300 }
1301
1302 _hg_cmd_unshelve() {
1303 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \
1304 '(--abort -a --continue -c --name -n :)'{-a,--abort}'[abort an incomplete unshelve operation]' \
1305 '(--abort -a --continue -c --name -n :)'{-c,--continue}'[continue an incomplete unshelve operation]' \
1306 '(--keep -k)'{-k,--keep}'[keep shelve after unshelving]' \
1307 '(--name -n :)'{-n+,--name=}'[restore shelved change with given name]:shelve:_hg_shelves' \
1308 ':shelve:_hg_shelves'
1309 }
1310
1262 _hg "$@" 1311 _hg "$@"