zsh: complete qapplied, qdiff, qfold, qguard, qimport, qnext, qprev
authorBrendan Cully <brendan@kublai.com>
Wed, 25 Oct 2006 19:31:42 -0700
changeset 3541 ee6b8de6df3c
parent 3540 91d0fee3e684
child 3542 bf48ca46139b
child 3544 4745cf66f77d
zsh: complete qapplied, qdiff, qfold, qguard, qimport, qnext, qprev as well as qrename, qselect, qseries, qunapplied and qtop.
contrib/zsh_completion
--- a/contrib/zsh_completion	Wed Oct 25 17:09:22 2006 -0700
+++ b/contrib/zsh_completion	Wed Oct 25 19:31:42 2006 -0700
@@ -164,24 +164,6 @@
   'directory:directory:_files -/'
 }
 
-_hg_qseries() {
-  typeset -a patches
-  patches=($(_hg_cmd qseries))
-  (( $#patches )) && _describe -t hg-patches 'patches' patches
-}
-
-_hg_qapplied() {
-  typeset -a patches
-  patches=($(_hg_cmd qapplied))
-  (( $#patches )) && _describe -t hg-applied-patches 'applied patches' patches
-}
-
-_hg_qunapplied() {
-  typeset -a patches
-  patches=($(_hg_cmd qunapplied))
-  (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
-}
-
 # Common options
 _hg_global_opts=(
     '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
@@ -516,11 +498,65 @@
 }
 
 # MQ
+_hg_qseries() {
+  typeset -a patches
+  patches=($(_hg_cmd qseries))
+  (( $#patches )) && _describe -t hg-patches 'patches' patches
+}
+
+_hg_qapplied() {
+  typeset -a patches
+  patches=($(_hg_cmd qapplied))
+  (( $#patches )) && _describe -t hg-applied-patches 'applied patches' patches
+}
+
+_hg_qunapplied() {
+  typeset -a patches
+  patches=($(_hg_cmd qunapplied))
+  (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
+}
+
+_hg_qguards() {
+  typeset -a guards
+  local guard
+  _hg_cmd qselect -s | while read guard
+  do
+    guards+=(${guard#(+|-)})
+  done
+  (( $#guards )) && _describe -t hg-guards 'guards' guards
+}
+
+_hg_qseries_opts=(
+  '(--summary -s)'{-s,--summary}'[print first line of patch header]')
+
+_hg_cmd_qapplied() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
 _hg_cmd_qdelete() {
   _arguments -s -w : $_hg_global_opts \
   '(--keep -k)'{-k,--keep}'[keep patch file]' \
   '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_qapplied' \
-  '*:patch:_hg_qunapplied'
+  '*:unapplied patch:_hg_qunapplied'
+}
+
+_hg_cmd_qdiff() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+  '*:pattern:_files -W $(_hg_cmd root)'
+}
+
+_hg_cmd_qfold() {
+  _arguments -s -w : $_hg_global_opts $_h_commit_opts \
+  '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
+  '*:unapplied patch:_hg_qunapplied'
+}
+
+_hg_cmd_qguard() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--list -l)'{-l,--list}'[list all patches and guards]' \
+  '(--none -n)'{-n,--none}'[drop all guards]' \
+  ':patch:_hg_qseries' \
+  '*:guards:_hg_qguards'
 }
 
 _hg_cmd_qheader() {
@@ -528,12 +564,25 @@
   ':patch:_hg_qseries'
 }
 
+_hg_cmd_qimport() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
+  '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
+  '(--force -f)'{-f,--force}'[overwrite existing files]' \
+  '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_tags' \
+  '*:patch:_files'
+}
+
 _hg_cmd_qnew() {
   _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
   '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
   ':patch:'
 }
 
+_hg_cmd_qnext() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
 _hg_cmd_qpop() {
   _arguments -s -w : $_hg_global_opts \
   '(--all -a :)'{-a,--all}'[pop all patches]' \
@@ -542,6 +591,10 @@
   ':patch:_hg_qapplied'
 }
 
+_hg_cmd_qprev() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
 _hg_cmd_qpush() {
   _arguments -s -w : $_hg_global_opts \
   '(--all -a :)'{-a,--all}'[apply all patches]' \
@@ -559,6 +612,34 @@
   '*:files:_files -W $(_hg_cmd root)'
 }
 
+_hg_cmd_qrename() {
+  _arguments -s -w : $_hg_global_opts \
+  ':patch:_hg_qseries' \
+  ':destination:'
+}
+
+_hg_cmd_qselect() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--none -n :)'{-n,--none}'[disable all guards]' \
+  '(--series -s :)'{-s,--series}'[list all guards in series file]' \
+  '--pop[pop to before first guarded applied patch]' \
+  '--reapply[pop and reapply patches]' \
+  '*:guards:_hg_qguards'
+}
+
+_hg_cmd_qseries() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
+  '(--missing -m)'{-m,--missing}'[print patches not in series]'
+}
+
+_hg_cmd_qunapplied() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
+_hg_cmd_qtop() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
 _hg_cmd_strip() {
   _arguments -s -w : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[force multi-head removal]' \