about summary refs log tree commit diff
path: root/Completion/Unix/Command/_bzr
blob: 23feb6f835f87bba563123462e77f2ad94c88d01 (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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#compdef bzr

# bzr is the bazaar-ng revision-control system

local curcontext="$curcontext" state line expl cmd args ret=1
typeset -A opt_args

_arguments -C \
    '1: :->cmd' \
    '*:: :->args' && ret=0

if (( ! $+_bzr_cmds )); then
    typeset -gH _bzr_cmds
    _bzr_cmds=(${(f)"$(_call_program bzr bzr shell-complete)"})
fi

if [[ $state != 'args' ]]; then
    _describe -t subcommand 'subcommand' _bzr_cmds
    return 0
fi

cmd="$words[1]"
curcontext="${curcontext%:*:*}:bzr-$cmd:"

(( $+functions[_bzr_unknownFiles] )) ||
_bzr_unknownFiles() {
    local fileList
    fileList=(${(ps:\0:)"$(bzr ls --null --unknown)"})
    compadd -af fileList
    return 0
}

(( $+functions[_bzr_unknownRoot] )) ||
_bzr_unknownRoot() {
    local fileList
    fileList=(${(ps:\0:)"$(bzr ls --null --from-root --unknown)"})
    compadd -af fileList
    return 0
}

(( $+functions[_bzr_versionedFiles] )) ||
_bzr_versionedFiles() {
    local fileList
    fileList=(${(ps:\0:)"$(bzr ls --null --versioned)"})
    compadd -af fileList
    return 0
}

(( $+functions[_bzr_completeParents] )) ||
_bzr_completeParents() {
    local parentFile=$(bzr root 2>/dev/null)/.bzr/branch/parent
    [[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile)
}

args=( '(-)'{--help,-h}'[show help message]' )

case $cmd in
(add)
    args+=(
	'--dry-run[show what would be added without adding anything]'
	'--no-recurse[do not recurse into subdirectories]'
	'(-q --quiet -v --verbose)'{--quiet,-q}'[be quiet]'
	'(-v --verbose -q --quiet)'{--verbose,-v}'[display more information]'
	'*:unknown files:_bzr_unknownFiles'
	)
    ;;

(annotate|blame|praise)
    args+=(
	'--all[show annotations on all lines]'
	'--long[show date in annotations]'
	'(-r --revision)'{--revision=,-r}'[the revision to show]:rev:'
	'*:files:_bzr_versionedFiles'
	)
    ;;

(branch|get|clone)
    args+=(
	'(-r --revision)'{--revision=,-r}'[the revision to get]:rev:'
	'--basis=[specify basis branch]:basis:'
	)
    if (( CURRENT == 2 )); then
	args+=( '*:FROM_LOCATION:_files -/' )
    elif (( CURRENT == 3 )); then
	args+=( '*:TO_LOCATION:_files -/' )
    fi
    ;;

(checkout|co)
    args+=(
	'--lightweight[perform a lightweight checkout]'
	'(-r --revision)'{--revision=,-r}'[the revision to get]:rev:'
	)
    _bzr_completeParents
    ;;

(rename|move|mv)
    if (( CURRENT == 2 )); then
	args+=( '*:files:_bzr_versionedFiles' )
    else
	args=( '*:destination dir:_files -/' )
    fi
    ;;

(cat)
    args+=(
	'(-r --revision)'{--revision=,-r}'[revision]:rev:'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(root)
    args+=( '*:file:_files' )
    ;;

(log)
    args+=(
	'--forward[reverse direction of revisions]'
	'(-l --long --short --log_format)--line[use log format with one line per revision. Same as "--log-format line"]'
	'(-l --long --short --line)--log-format=[use the specified log format]:log format:(line short long)'
	'(-l --long --short --line --log-format)'{--long,-l}'[use detailed log format. Same as "--log-format long"]'
	'(-l --long --log_format)--short[use moderately short log format. Same as "--log-format short"]'
	'(-m --message)'{--message=,-m}'[specify regexp]:regexp:'
	'(-r --revision)'{--revision=,-r}'[revision or range]:rev or rev range:'
	'--show-ids[show file IDs]'
	'--timezone=[specify timezone for dates]:timezone:'
	'(-v --verbose)'{--verbose,-v}'[show revision manifest]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(resolve|resolved)
    args+=(
	'--all[resolve all conflicts in this tree]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(status|st|stat)
    args+=(
	'--all[include unchanged versioned files]'
	'(-r --revision)'{--revision=,-r}'[compare working tree with revision]:revision:'
	'--show-ids[show file IDs]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(check)
    args+=(
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:DIR:_files -/'
	)
    ;;

(mkdir|renames|update)
    args+=( '*:DIR:_files -/' )
    ;;

(init|upgrade)
    args+=(
	'--format=[format for repository]:format:(default knit metaweave weave)'
	'*:DIR:_files -/'
	)
    ;;

(init-repo|init-repository)
    args+=(
	'--format=[format for repository]:format:(default knit metaweave weave)'
	'--trees[allows branches in repository to have a working tree]'
	'*:DIR:_files -/'
	)
    ;;

(remove|rm)
    args+=(
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(pull)
    args+=(
	'--overwrite[ignore differences, overwrite unconditionally]'
	'--remember[remember the specified location as a default]'
	'(-r --revision)'{--revision=,-r}'[get a particular revision]:revision:'
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(missing)
    args+=(
	'(-l --long --short --log_format)--line[use log format with one line per revision. Same as "--log-format line"]'
	'(-l --long --short --line)--log-format=[use the specified log format]:log format:(line short long)'
	'(-l --long --short --line --log-format)'{--long,-l}'[use detailed log format. Same as "--log-format long"]'
	'(-l --long --log_format)--short[use moderately short log format. Same as "--log-format short"]'
	'--mine-only[display changes in the local branch only]'
	'--reverse[reverse the order of revisions]'
	'--show-ids[show internal object ids]'
	'--theirs-only[display changes in the remote branch only]'
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(commit|checkin|ci)
    args+=(
	'(-F --file)'{--file=,-F}'[commit message from file]:message file:'
	'--local[perform a local only commit in a bound branch]'
	'(-m --message)'{--message=,-m}'[commit message]:message text:'
	'--strict[refuse to commit if there are unknown files]'
	'--unchanged[include unchanged files]'
	'(-q --quiet -v --verbose)'{--quiet,-q}'[be quiet]'
	'(-v --verbose -q --quiet)'{--verbose,-v}'[display more information]'
	'*:modified files:_bzr_versionedFiles'
	)
    ;;

(bind|break-lock|reconcile)
    _bzr_completeParents
    ;;

(register-branch)
    args+=(
	'--author=[email of the branch author, if not you]:email:'
	'--branch-description=[longer description of the branch]:description:'
	'--branch-name=[short name for the branch]:name:'
	'--branch-title=[one-sentence description of the branch]:title:'
	'--dry-run[prepare the request but do not actually send it]'
	'--link-bug=[the bug this branch fixes]:bug-ID:'
	'--product=[launchpad product short name to associate with the branch]:product:'
	)
    _bzr_completeParents
    ;;

(remerge)
    args+=(
	'--merge-type=[the type of the merge]:type:'
	'--reprocess[reprocess to reduce spurious conflicts]'
	'--show-base[show base revision text in conflicts]'
	)
    _bzr_completeParents
    ;;

(conflicts|added|deleted|modified|unknowns|directories|ignored|unbind|nick|revno|version)
    ;;

(whoami)
    args+=( '--email[only show e-mail address]' )
    ;;

(inventory)
    args+=(
	'--kind=[limit output by type]:kind:(file directory symlink)'
	'(-r --revision)'{--revision=,-r}'[show inventory of a revision]:revision:'
	'--show-ids[show file IDs]'
	)
    ;;

(diff|dif|di|cdiff)
    args+=(
	'(-r --revision)'{--revision=,-r}'[revision]:revision:'
	'--diff-options=[options to pass to gdiff]:diff options:'
	'(-p --prefix)'{--prefix,-p}'[set prefix added to old and new filenames]'
	'*:files:_files'
	)
    ;;

(export)
    args+=(
	'(-r --revision)'{--revision=,-r}'[revision]:revision:'
	'--format=[format of exported file]:format:(dir tar tgz tbz2)'
	'--root=[root directory of patch]:_files -/'
	'*:destination:_files'
	)
    ;;

(ignore)
    args+=( '*:NAME_PATTERN:_bzr_unknownRoot' )
    ;;

(info)
    args+=(
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	'*:branch:_files -/'
	)
    ;;

(testament)
    args+=(
	'(-l --long)'{--long,-l}'[use long format]'
	'(-r --revision)'{--revision=,-r}'[revision]:revision:'
	'*:branch:_files -/'
	)
    ;;

(revert|merge-revert)
    args+=(
	'--no-backup[skip generation of backup~ files]'
	'(-r --revision)'{--revision=,-r}'[revision]:revision:'
	'*:file:_bzr_versionedFiles'
	)
    ;;

(merge)
    args+=(
	'--force[ignore uncommitted changes]'
	'--merge-type:merge type:(diff3 merge3 weave)'
	'--remember[remember the specified location as a default]'
	'--reprocess[reprocess to reduce spurious conflicts]'
	'(-r --revision)'{--revision=,-r}'[revision]:revision:'
	'--show-base[show base revision text in conflicts]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(ls)
    args+=(
	'(-q --quiet -v --verbose)'{--quiet,-q}'[be quiet]'
	'(-v --verbose -q --quiet)'{--verbose,-v}'[display more information]'
	'(-r --revision)'{--revision=,-r}'[revision]: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]'
	)
    ;;

(switch)
    args+=(
	'--force[switch even if local commits will be lost]'
	'(-q --quiet -v --verbose)'{--quiet,-q}'[be quiet]'
	'(-v --verbose -q --quiet)'{--verbose,-v}'[display more information]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(help)
    args=(
	'(-l --long)'{--long,-l}'[use long format]'
	'*:subcmds:->cmds'
	)
    _arguments -s "$args[@]" && ret=0
    _describe -t subcommand 'subcommand' _bzr_cmds
    return 0
    ;;

    # Plugins

(visualize|visualise|viz|vis)
    args+=( '(-r --revision)'{--revision=,-r}'[starting revision]:rev:' )
    ;;

(gannotate|gblame|gpraise)
    args+=(
	'--all[show annotations on all lines]'
	'--plain[do not hightlight annotation lines]'
	'*:files:_bzr_versionedFiles'
	)
    ;;

(push)
    args+=(
	'--create-prefix[create the path leading up to the branch when missing]'
	'--overwrite[ignore differences, overwrite unconditionally]'
	'--remember[remember the specified location as a default]'
	'*:local repository:_files -/'
	)
    _bzr_completeParents
    ;;

(clean-tree)
    args+=(
	'--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]'
	)
    ;;

(uncommit)
    args+=(
	'--dry-run[do not make any changes]'
	'--force[say "yes" to all questions]'
	'(-r --revision)'{--revision=,-r}'[the earliest revision to delete]:rev:'
	'(-v --verbose)'{--verbose,-v}'[display more information]'
	)
    ;;

(sign-my-commits)
    args+=( '--dry-run[do not actually sign anything]' )
    ;;

(send)
    args+=( '*:DIR:_files -/' )
    ;;

(*)
    _message "unknown bzr command completion: $cmd"
    return 1
    ;;
esac

_arguments -s "$args[@]" && ret=0
return $ret