blob: 65fa87904a64fc0f27bdc5153036dac6effe4dba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
#compdef cvs
_cvs () {
setopt localoptions extendedglob
typeset -A commands
commands=(add "ad new" admin "adm rcs" annotate ann
checkout "co get" commit "ci com" diff "di dif"
edit "" editors "" export "exp ex"
history "hi his" import "im imp" init ""
log "lo rlog" login "logon lgn" logout ""
rdiff patch release "re rel" remove "rm delete"
status "st stat" rtag "rt rfreeze" tag "ta freeze"
unedit "" update "up upd" watch ""
watchers "")
local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
local showlist='compstate[list]=list; compstate[force_list]=yes'
local showhint="$showlist ; compstate[insert]=''"
local complete_D="compadd today yesterday week\\ ago month\\ ago"
local complete_k="compadd kv kvl k o b v"
local complete_r="_cvsrevisions"
local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
if (( com < CURRENT )); then
case "$words[$com]" in
add|ad|new) # "+k:m:"
_complete_opts k: "$complete_k" m: "$complete_m" || _cvsaddp
;;
admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
_complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' \
U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' \
V: '' k: "$complete_k" ||
_cvstargets
;;
annotate|ann) # "+lr:D:fR"
_complete_opts l '' r: "$complete_r" D: "$complete_D" f '' R '' ||
_cvstargets
;;
checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
_complete_opts A '' N '' n '' k: "$complete_k" d: '_files -/' f '' \
l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" \
j: "$complete_r" P '' ||
_cvsrepositories
;;
commit|ci|com) # "+nlRm:fF:r:"
_complete_opts n '' l '' R '' m: "$complete_m" f '' F: _files \
r: "$complete_r" ||
_cvsmodified
;;
diff|di|dif) # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:"
_complete_opts a '' b '' c '' d '' e '' f '' h '' i '' l '' n '' p '' \
s '' t '' u '' w '' 0 '' 1 '' 2 '' 3 '' 4 '' 5 '' 6 '' 7 '' 8 '' \
9 '' B '' H '' N '' R '' C: '' D: "$complete_D" F: '' I: '' L: '' \
U: '' V: '' W: '' k: "$complete_k" r: "$complete_r" ||
_cvsmodified || _cvstargets
;;
edit) # "+lRa:"
_complete_opts l '' R '' a: 'compadd edit unedit commit all none' ||
_cvstargets
;;
editors) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
export|exp|ex) # "+Nnk:d:flRQqr:D:"
_complete_opts N '' n '' k: "$complete_k" d: '_files -/' f '' l '' \
R '' Q '' q '' r: "$complete_r" D: "$complete_D" ||
_cvsrepositories
;;
history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
_complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' \
D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' \
t: '' u: '' x: '' X: '' z: '' ||
_cvstargets
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
_complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: _files \
k: "$complete_k" W: '' ||
case $[CURRENT-com] in
1) _cvsrepositories;;
2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
*) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
esac
;;
init)
break
;;
login|logon|lgn|logout)
_complete_opts || _files
;;
rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
_complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' \
q '' l '' R '' D: "$complete_D" r: "$complete_r" ||
_cvstargets
;;
release|re|rel) # "+Qdq"
_complete_opts Q '' d '' q '' || _files -/
;;
remove|rm|delete) # "+flR"
_complete_opts f '' l '' R '' || _cvsremovep
;;
status|st|stat) # "+vlR"
_complete_opts v '' l '' R '' || _cvstargets
;;
tag|ta|freeze) # "+FQqlRcdr:D:bf"
_complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" \
D: "$complete_D" b '' f '' ||
_cvstargets
;;
unedit) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
_complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' \
k: "$complete_k" r: "$complete_r" D: "$complete_D" j: "$complete_r" \
I: '' W: '' ||
_cvstargets
;;
watch)
if (( CURRENT == com + 1 )); then
compadd on off add remove
else
case "$words[com+1]" in
on|off) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
add|remove) # "+lRa:"
_complete_opts l '' R '' \
a: 'compadd edit unedit commit all none' || \
_cvstargets
;;
esac
fi
;;
watchers) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
*) _files;;
esac
return
fi
_complete_opts \
H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
b: "compadd /usr/local/bin" \
T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
e: "compadd vi" \
d: "compadd $_cvs_roots || _files -/" \
z: "compadd 9'" \
s: "_cvs_user_variable" \
||
compadd ${(k)commands} ||
compadd ${(kv)=commands}
}
_cvsrevisions () {
compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##}%%[ ]*}
}
_cvsrepositories () {
local root=$CVSROOT
[[ -f CVS/Root ]] && root=$(<CVS/Root)
if [[ $root = :* || ! -d $root ]]; then
compadd -UX "Enter repository name" -n '' &&
{ compstate[list]=list; compstate[force_list]=yes; compstate[insert]='' }
else
compadd - \
$root/^CVSROOT(:t) \
${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*}
fi
}
_cvsprefix () {
if [[ -prefix */ ]]; then
qpref="${PREFIX%/*}/"
pref=$~qpref
else
qpref=
pref=./
fi
}
_cvsentries_dir () {
entries=($entries ${${${(M)rawentries:#D/*}#D/}%%/*})
}
_cvsentries_plain () {
entries=($entries ${${${(M)rawentries:#/*}#/}%%/*})
}
_cvsentries_modified () {
if (( $+_cvsentries_modified_disable_stat )) ||
! { zmodload -e stat || zmodload stat }; then
_cvsentries_plain
return
fi
local ents pats
ents=(${${${${(M)rawentries:#/*}#/}/\\/[^\\/]#\\///}%/[^/]#/[^/]#})
pats=(${${${(f)"$(LANG=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${pref}*(D))"}##*/}/ //})
eval 'ents=(${ents:#('${(j:|:)pats:q}')})'
entries=($entries ${ents%%/*})
}
_cvsdirentries () {
entries=()
if [[ -f ${pref}CVS/Entries ]]; then
local rawentries
rawentries=(${(f)"$(<${pref}CVS/Entries)"})
_cvsentries_dir
fi
}
_cvsentries () {
entries=()
if [[ -f ${pref}CVS/Entries ]]; then
local rawentries
rawentries=(${(f)"$(<${pref}CVS/Entries)"})
_cvsentries_plain
_cvsentries_dir
fi
}
_cvsmodentries () {
entries=()
if [[ -f ${pref}CVS/Entries ]]; then
local rawentries
rawentries=(${(f)"$(<${pref}CVS/Entries)"})
_cvsentries_modified
_cvsentries_dir
fi
}
_cvsdirs () {
if [[ -d ${pref}CVS ]]; then
_cvsdirentries
case $#entries in
0) false;;
1) compgen "$@" -g "${entries:q}";;
*) compgen "$@" -g '('${(j:|:)entries:q}')';;
esac
else
_files
fi
}
_cvstargets () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
case $#entries in
0) false;;
1) compgen -g "${entries:q}";;
*) compgen -g '('${(j:|:)entries:q}')';;
esac
else
_files
fi
}
_cvsmodified () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsmodentries
case $#entries in
0) false;;
1) compgen -g "${entries:q}";;
*) compgen -g '('${(j:|:)entries:q}')';;
esac
else
_files
fi
}
_cvsremovep () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local omit
omit=(${pref}*(D:t))
eval 'entries=(${entries:#('${(j:|:)omit:q}')})'
compadd -P "$qpref" - ${entries:q} ||
_cvsdirs
else
_files
fi
}
_cvsaddp () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local omit
omit=($_cvs_ignore_default ${entries:q} ${=cvsignore})
[[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore))
[[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore))
compgen -g '*~(*/|)('${(j:|:)omit}')(D)' ||
compgen -g '*~(*/|)('${(j:|:)entries:q}')(D)' ||
_cvsdirs
else
_files
fi
}
if (( ! $+_cvs_ignore_default )); then
_cvs_ignore_default=(
RCS SCCS CVS CVS.adm RCSLOG 'cvslog.*' tags TAGS .make.state .nse_depinfo
'*\~' '\#*' '.\#*' ',*' '_$*' '*$' '*.old' '*.bak' '*.BAK' '*.orig' '*.rej'
'.del-*' '*.a' '*.olb' '*.o' '*.obj' '*.so' '*.exe' '*.Z' '*.elc' '*.ln'
core
)
fi
if (( ! $+_cvs_roots )); then
if [[ -f ~/.cvspass ]]; then
_cvs_roots=(${${(f)"$(<~/.cvspass)"}%% *})
else
_cvs_roots=()
fi
fi
_cvs "$@"
|