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
|
#compdef bzr
# Rudimentary zsh completion support for bzr.
# -S means there are no options after a -- and that argument is ignored
# To use this you must arrange for it to be in a directory that is on
# your $fpath, and also for compinit to be run. I don't understand
# how to get zsh to reload this file when it changes, other than by
# starting a new zsh.
local _bzr_subcommands expl curcontext="$curcontext" state line
local bzrRoot helpArgs parentFile
typeset -A opt_args
helpArgs=( '(--help)-h[show help message]' '(-h)--help[show help message]' )
bzrRoot=$(bzr root 2> /dev/null)
parentFile=$bzrRoot/.bzr/parent
if [[ $service == "bzr" ]]; then
_arguments -C -A "-*" \
'*::command:->subcmd' && return 0
if (( CURRENT == 1 )); then
_bzr_subcommands=(${(f)"$(_call_program bzr bzr shell-complete)"})
_describe -t subcommand 'subcommand' _bzr_subcommands
return
fi
service="$words[1]"
curcontext="${curcontext%:*}=$service:"
fi
_unknownFiles() {
local fileList;
fileList=(${(ps:\0:)"$(bzr ls --null --unknown)"})
compadd -af fileList
return 0
}
_unknownRoot() {
local fileList;
fileList=(${(ps:\0:)"$(bzr ls --null --from-root --unknown)"})
compadd -af fileList
return 0
}
_versionedFiles() {
local fileList;
fileList=(${(ps:\0:)"$(bzr ls --null --versioned)"})
compadd -af fileList
return 0
}
case $service in
(add)
_arguments $helpArgs \
'--no-recurse[do not recurse into subdirectories]' \
'(-q)--quiet' \
'(--quiet)-q' \
'*:unknown files:_unknownFiles'
;;
(annotate|praise|blame)
_arguments $helpArgs '*:files:_versionedFiles'
;;
(clone|branch|get)
if (( CURRENT == 2 )); then
_arguments $helpArgs \
'(-r)--revision:rev:' \
'(--revision)-r:rev:' \
'--basis[specify basis branch]:basis:' \
'*:FROM_LOCATION:_files -/'
elif (( CURRENT == 3 )); then
_arguments $helpArgs \
'(-r)--revision:rev:' \
'(--revision)-r:rev:' \
'--basis[specify basis branch]:basis:' \
'*:TO_LOCATION:_files -/'
fi
;;
(rename|mv)
if (( CURRENT == 2 )); then
_arguments $helpArgs '*:old name:_versionedFiles'
else
_arguments $helpArgs '*:new name:'
fi
;;
(cat)
_arguments $helpArgs \
'(-r)--revision:rev:' \
'(--revision)-r:rev:' \
'*:file:_versionedFiles'
;;
(root)
_arguments $helpArgs '*:file:_files'
;;
(log)
_arguments $helpArgs \
'(-r)--revision[revision or range]:rev or rev range:' \
'(--revision)-r[revision or range]:rev or rev range:' \
'(--verbose)-v[show revision manifest]' \
'(-v)--verbose[show revision manifest]' \
'(--short --long)-l[use long format (default)]' \
'(--short -l)--long[use long format (default)]' \
'(-l --long)--short[use short format]' \
'(--message)-m[specify regexp]:regexp:' \
'(-m)--message[specify regexp]:regexp:' \
'--show-ids[show file IDs]' \
'--forward[reverse direction of revisions]' \
'--timezoe[specify timezone for dates]:timezone:' \
'*:file:_versionedFiles'
;;
(resolve)
_arguments $helpArgs '--all' '*:file:_versionedFiles'
;;
(status|st|stat)
_arguments $helpArgs \
'--all[include unchanged versioned files]' \
'--show-ids[show file IDs]' \
'*:file:_versionedFiles'
;;
(check)
_arguments $helpArgs \
'(--verbose)-v' \
'(-v)--verbose' \
'*:DIR:_files -/'
;;
(mkdir|upgrade|renames)
_arguments $helpArgs '*:DIR:_files -/'
;;
(remove|rm)
_arguments $helpArgs \
'(--verbose)-v' \
'(-v)--verbose' \
'*:file:_versionedFiles'
;;
(pull)
_arguments $helpArgs \
'--remember[Remember the specified location as a default]' \
'--overwrite[Ignore differences, overwrite unconditionally]' \
'*:local repository:_files -/'
[[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile)
;;
(missing|miss|mis)
_arguments $helpArgs \
'(--verbose -q --quiet)-v' \
'(-v -q --quiet)--verbose' \
'(--verbose -v --quiet)-q' \
'(-v -q --verbose)--quiet' \
'*:local repository:_files -/'
[[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile)
;;
(commit|checkin|ci)
_arguments $helpArgs \
'(--message)-m[commit message]:message text:' \
'(-m)--message[commit message]:message text:' \
'(--file)-F[commit message from file]:message file:' \
'(-F)--file[commit message from file]:message file:' \
'--unchanged[include unchanged files]' \
'(--verbose)-v' \
'(-v)--verbose' \
'*:modified files:_versionedFiles'
;;
(conflicts|added|deleted|modified|unknowns|directories|ignored)
_arguments $helpArgs
;;
(revno|init|version)
_arguments $helpArgs
;;
(whoami)
_arguments $helpArgs '--email[only show e-mail address]'
;;
(inventory)
_arguments $helpArgs \
'(-r)--revision[show inventory of a revision]:revision:' \
'(--revision)-r[show inventory of a revision]:revision:' \
'--show-ids[show file IDs]'
;;
(diff|dif|di)
_arguments $helpArgs \
'(-r)--revision:revision:' \
'(--revision)-r:revision:' \
'--diff-options[options to pass to gdiff]:diff options:' \
'*:files:_files'
;;
(export)
_arguments $helpArgs \
'(-r)--revision:revision:' \
'(--revision)-r:revision:' \
'--format=[format of exported file]:format:(dir tar tgz tbz2)' \
'--root[root directory of patch]:_files -/' \
'*:destination:_files'
;;
(ignore)
_arguments $helpArgs '*:NAME_PATTERN:_unknownRoot'
;;
(info)
_arguments $helpArgs '*:branch:_files -/'
;;
(testament)
_arguments $helpArgs \
'(-r)--revision:revision:' \
'(--revision)-r:revision:' \
'(--long)-l' \
'(-l)--long' \
'*:branch:_files -/'
;;
(revert|merge-revert)
_arguments $helpArgs \
'(-r)--revision:revision:' \
'(--revision)-r:revision:' \
'--no-backup[skip generation of backup~ files]' \
'*:file:_versionedFiles'
;;
(merge)
_arguments $helpArgs \
'(-r)--revision:revision:' \
'(--revision)-r:revision:' \
'--reprocess[Reprocess to reduce spurious conflicts]' \
'--show-base[Show base revision text in conflicts]' \
'--force[ignore uncommitted changes]' \
'--merge-type:merge type:(diff3 merge3 weave)' \
'*:local repository:_files -/'
[[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile)
;;
(ls)
_arguments $helpArgs \
'(--verbose)-v[display more information]' \
'(-v)--verbose[display more information]' \
'(-r)--revision:revision:' \
'(--revision)-r:revision:' \
'--from-root[Print all paths from the root of the branch]' \
'--non-recursive[Do not recurse into subdirectories]' \
'--null[Null separate the files]' \
'--ignored[Print ignored files]' \
'--unknown[Print unknown files]' \
'--versioned[Print versioned files]'
;;
(move)
if (( CURRENT == 2 )); then
_arguments $helpArgs '*:files:_versionedFiles'
else
_arguments '*:destination dir:_files -/'
fi
;;
(help)
_bzr_subcommands=(${(f)"$(_call_program bzr bzr shell-complete)"})
_arguments $helpArgs \
'(--long)-l' \
'(-l)--long' \
'*:subcmds:->cmds'
_describe -t subcommand 'subcommand' _bzr_subcommands
;;
# Plugins
(visualize|visualise|viz|vis)
_arguments $helpArgs \
'(-r)--revision[starting revision]:rev:' \
'(--revision)-r[starting revision]:rev:'
;;
(gannotate|gblame|gpraise)
_arguments $helpArgs \
'--all[show annotations on all lines]' \
'--plain[do not hightlight annotation lines]' \
'*:files:_versionedFiles'
;;
(push)
_arguments $helpArgs \
'--overwrite[Ignore differences, overwrite unconditionally]' \
'*:local repository:_files -/'
[[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile)
;;
(clean-tree)
_arguments $helpArgs \
'--dry-run[show files to delete instead of deleting them]' \
'--ignored[delete all ignored files]' \
'--detritus[delete conflict files, merge backups, failed self-tests, *~, *.tmp, etc]'
;;
(*)
_message "unknown bzr command completion: $service"
;;
esac
|