changeset 3487:46958e428fcd

zsh completion: basic mq support
author Brendan Cully <brendan@kublai.com>
date Sat, 21 Oct 2006 23:51:36 -0700
parents f699d4eb25d9
children 8f02223662c8
files contrib/zsh_completion
diffstat 1 files changed, 57 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/zsh_completion	Sun Oct 22 01:02:13 2006 -0300
+++ b/contrib/zsh_completion	Sat Oct 21 23:51:36 2006 -0700
@@ -14,7 +14,18 @@
 
 local curcontext="$curcontext" state line
 typeset -A opt_args
-local subcmds repos tags newFiles addedFiles includeExclude
+local subcmds repos tags newFiles addedFiles includeExclude commitMessage
+
+_mq_state () {
+  case "$state" in
+    (qapplied)
+      compadd $(hg qapplied)
+    ;;
+    (qunapplied)
+      compadd $(hg qunapplied)
+    ;;
+  esac
+}
 
 tags=($(hg tags 2> /dev/null | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//'))
 subcmds=($(hg -v help | sed -e '1,/^list of commands:/d' \
@@ -27,6 +38,14 @@
         '*-X-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/'
         '*--exclude-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/')
 
+commitMessage=(
+        '(-m --message -l --logfile --edit)-e[edit commit message]'
+        '(-m --message -l --logfile -e)--edit[edit commit message]'
+        '(-e --edit -l --logfile --message)-m[use <text> as commit message]:message:'
+        '(-e --edit -l --logfile -m)--message[use <text> as commit message]:message:'
+        '(-e --edit -m --message --logfile)-l[read the commit message from <file>]:log file:_files'
+        '(-e --edit -m --message -l)--logfile[read the commit message from <file>]:log file:_files')
+
 if [[ $service == "hg" ]]; then
     _arguments -C -A "-*" \
     '(--repository)-R[repository root directory]:root:_files -/' \
@@ -419,6 +438,43 @@
         # no arguments for these commands
     ;;
 
+    # MQ commands
+    (qdel*|qrm|qrem*)
+        _arguments \
+            {-k,--keep}'[keep patch file]' \
+            {-r,--rev}'[revision]:applied patch:->qapplied' \
+            '*:unapplied patches:->qunapplied'
+        _mq_state
+    ;;
+
+    (qnew)
+        _arguments $commitMessage \
+            {-f,--force}'[import uncommitted changes into patch]' \
+            ':patch name:'
+    ;;
+
+    (qpo*)
+        applied=( $(hg qapplied) )
+        _arguments \
+            (1){-a,--all}'[pop all patches]' \
+            {-f,--force}'[forget any local changes]' \
+            ':applied patch:->qapplied'
+        _mq_state
+    ;;
+
+    (qpu*)
+        _arguments \
+            (1){-a,--all}'[apply all patches]' \
+            {-f,--force}'[apply if the patch has rejects]' \
+            ':unapplied patch:->qunapplied'
+        _mq_state
+    ;;
+    (qref*)
+        _arguments $commitMessage $includeExclude \
+            {-g,--git}'[use git extended diff format]' \
+            {-s,--short}'[short refresh]'
+    ;;
+
     (*)
         _message "unknown hg command completion: $service"
     ;;