annotate .zfun/_subversion @ 77:45d7441d0cf2

Modularize .emacs
author Augie Fackler <durin42@gmail.com>
date Thu, 09 Apr 2009 13:39:20 -0500
parents b84c4cac3148
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 #compdef svn svnadmin svnadmin-static=svnadmin
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 _svn () {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 local curcontext="$curcontext" state line expl ret=1
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 _arguments -C \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 '(-)--help[print help information]' \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 '(- *)--version[print client version information]' \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 '1: :->cmds' \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 '*:: :->args' && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 if [[ -n $state ]] && (( ! $+_svn_cmds )); then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 typeset -gHA _svn_cmds
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 _svn_cmds=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 ${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 case $state in
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 cmds)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 _wanted commands expl 'svn command' _svn_commands && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 args)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 local cmd args usage
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 typeset -gHA _cache_svn_status
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 if (( $#cmd )); then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 curcontext="${curcontext%:*:*}:svn-${cmd}:"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 args=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"##*Valid options:}:#* :*}%% #:*}/ ARG/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 case $cmd in;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 (add)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 '*:file:_files -g "*(^e:_svn_controlled:)"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 (commit)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 args=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 ${args/(#b)(*--file*):arg:/$match[1]:file:_files}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 '*:file:_files -g "*(e:_svn_status:)"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 (delete)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 (diff)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 '*: : _alternative "files:file:_files -g \*\(e:_svn_status:\)" "urls:URL:_svn_urls"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 (help)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 '*::sub command:_svn_commands'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 (import)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 '1:project directory or import location: _alternative "files:file:_files" "urls:URL:_svn_urls"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 '2:import location: _alternative "files:file:_files" "urls:URL:_svn_urls"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 (log)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 '1: : _alternative "files:file:_files -g \*\(e:_svn_controlled:\)" "urls:URL:_svn_urls"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 '*:file:_files -g "*(e:_svn_controlled:)"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 (propset)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 args=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 ':propname:(svn:ignore svn:keywords svn:executable svn:eol-style svn:mime-type svn:externals svn:needs-lock)'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 ${args/(#b)(*--file*):arg:/$match[1]:file:_files}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 '*:path or url: _alternative "files:file:_files" "urls:URL:_svn_urls"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 (resolved)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 '*:file:_files -g "*(e:_svn_conflicts:)"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 (revert)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 (*)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 case $usage in
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 *(SRC|DST|TARGET|URL*PATH)*)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 args+=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 '*: : _alternative "files:file:_files" "urls:URL:_svn_urls"'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 *URL*) args+=( ':URL:_svn_urls' ) ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100 *PATH*) args+=( '*:file:_files' ) ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 esac
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 esac
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 _arguments "$args[@]" && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 else
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108 _message "unknown svn command: $words[1]"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 esac
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 return ret
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 _svnadmin () {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 local curcontext="$curcontext" state line ret=1
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 _arguments -C \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 '(-)--help[print help information]' \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 '(- *)--version[print client version information]' \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 '1: :->cmds' \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 '*:: :->args' && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 if [[ -n $state ]] && (( ! $+_svnadmin_cmds )); then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 typeset -gHA _svnadmin_cmds
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 _svnadmin_cmds=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 ${=${(f)${${"$(LC_ALL=C _call_program commands svnadmin help)"#l#*Available subcommands:}}}/(#s)[[:space:]]#(#b)([-a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 case $state in
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 cmds)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 _wanted commands expl 'svnadmin command' _svnadmin_commands && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 args)
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 local cmd args usage
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139 cmd="${${(k)_svnadmin_cmds[(R)*:$words[1]:*]}:-${(k)_svnadmin_cmds[(i):$words[1]:]}}"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 if (( $#cmd )); then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 curcontext="${curcontext%:*:*}:svnadmin-${cmd}:"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 usage=${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"}:#$cmd: usage:*}#$cmd: usage: svnadmin $cmd }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 args=(
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"##*Valid options:}:#*:*}%% #:*}/ ARG/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 if [[ $_svnadmin_subcmd_usage == *REPOS_PATH* ]]; then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 args+=( ":path:_files -/" )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 elif [[ $cmd = help ]]; then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 args+=( "*:subcommand:_svnadmin_commands" )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 _arguments "$args[@]" && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154 else
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 _message "unknown svnadmin command: $words[1]"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 esac
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 return ret
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163 (( $+functions[_svn_controlled] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 _svn_controlled() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]]
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168 (( $+functions[_svn_conflicts] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169 _svn_conflicts() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 [ -n $REPLY.(mine|r<->)(N[1]) ]
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 (( $+functions[_svn_deletedfiles] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 _svn_deletedfiles() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 local cont controlled
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 reply=( )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 [[ $REPLY = (*/|).svn ]] || return
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179 controlled=( $REPLY/text-base/*.svn-base(N:r:t) )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180 for cont in ${controlled}; do
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181 [[ -e $REPLY:h/$cont ]] || reply+=( ${REPLY%.svn}$cont )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182 done
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
183 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 (( $+functions[_svn_status] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 _svn_status() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
187 local dir=$REPLY:h
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
188 local pat="${1:-([ADMR~]|?M)}"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
189
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
190 if (( ! $+_cache_svn_status[$dir] )); then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191 _cache_svn_status[$dir]="$(_call_program files svn status -N $dir)"
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
194 (( ${(M)#${(f)_cache_svn_status[$dir]}:#(#s)${~pat}*$REPLY} ))
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 (( $+functions[_svn_urls] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
198 _svn_urls() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 local expl remfiles remdispf remdispd suf ret=1
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201 if [[ -prefix *: ]] && ! _urls &&
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
202 zstyle -T ":completion:${curcontext}:" remote-access
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
203 then
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
204 remfiles=( ${(f)"$(svn list $IPREFIX${PREFIX%%[^./][^/]#} 2>/dev/null)"} )
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
205 compset -P '*/'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
206 compset -S '/*' || suf=file
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
207 remdispf=(${remfiles:#*/})
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
208 remdispd=(${(M)remfiles:#*/})
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
209 _tags files
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
210 while _tags; do
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 while _next_label files expl ${suf:-directory}; do
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf $remdispf && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213 compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 ${remdispd%/} && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
215 done
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
216 (( ret )) || return 0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
217 done
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
218 else
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
219 compset -S '[^:]*'
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
220 _wanted url-schemas expl 'URL schema' compadd -S '' - \
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
221 file:// http:// https:// svn:// svn+ssh:// && ret=0
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222 fi
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
223
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224 return ret
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
225 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
227 (( $+functions[_svn_commands] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
228 _svn_commands() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
229 compadd "$@" -k _svn_cmds || compadd "$@" ${(s.:.)_svn_cmds}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
230 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
232 (( $+functions[_svnadmin_command] )) ||
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
233 _svnadmin_commands() {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
234 compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(s.:.)_svnadmin_cmds}
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
235 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
237 _subversion () {
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
238 case $service in
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
239 (svn) _svn "$@" ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
240 (svnadmin) _svnadmin "$@" ;;
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
241 esac
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
242 }
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243
b84c4cac3148 Add custom _subversion that works with svn 1.5 and later.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244 _subversion "$@"