1# (C) 2011-2012 magicant
2
3# Completion script for the "svn" command.
4# Supports Subversion 1.7.
5
6function completion/svn {
7
8	typeset OPTIONS COMMONOPTIONS ADDOPTIONS ARGOPT PREFIX
9	COMMONOPTIONS=( #>#
10	"--config-dir:; specify a directory containing configuration files"
11	"--config-option:; specify a configuration option"
12	"h ? --help; print help"
13	"--no-auth-cache; don't cache user name and password"
14	"--non-interactive; disable interactive prompt"
15	"--password:; specify a password for authentication"
16	"--trust-server-cert; accept suspicious SSL server certificate"
17	"--username:; specify a user name for authentication"
18	) #<#
19	ADDOPTIONS=( #>#
20	"--accept:; specify an action for conflict resolution"
21	"--allow-mixed-revisions" # not documented as not recommended
22	"--auto-props; enable automatic property setting"
23	"c: --change:; specify a change (revision)"
24	"--changelist: --cl:; specify a changelist to operate on"
25	"--depth:; specify directory depth to operate on"
26	"--diff; show diff"
27	"--diff-cmd:; specify an external program to be used as \"diff\""
28	"--diff3-cmd:; specify an external program to be used as \"diff3\""
29	"--dry-run; don't make any actual changes"
30	"--editor-cmd:; specify an external program to be used as an editor"
31	"--encoding:; specify the encoding of the log message"
32	"x: --extensions:; specify arguments that is passed to the external diff command"
33	"F: --file:; use the specified file's contents instead of invoking an editor"
34	"--force; force operation to run"
35	"--force-log; accept a suspicious parameter value for log messages"
36	"--git; print in Git-like format"
37	"--ignore-ancestry; ignore ancestry when calculating differences"
38	"--ignore-externals; ignore externals and its working copies"
39	"--ignore-whitespace; tolerate whitespace mismatches"
40	"--incremental; print output in a format suitable for concatenation"
41	"--keep-changelists; don't delete changelists after committing"
42	"--keep-local; keep the local working copy"
43	"l: --limit:; specify the number of log messages to be shown"
44	"m: --message:; specify a log message"
45	"--native-eol:; specify an end-of-line marker for native EOL settings"
46	"--new:; specify the newer one of the compared files"
47	"--no-auto-props; disable automatic property setting"
48	"--no-diff-deleted; don't print diff for deleted files"
49	"--no-ignore; don't ignore files"
50	"--no-unlock; don't unlock files after committing"
51	#deprecated "N --non-recursive"
52	"--notice-ancestry; take ancestry into account when making a diff"
53	"--old:; specify the older one of the compared files"
54	"--parents; create nonexistent parent directories"
55	"q --quiet; print essential information only"
56	"--record-only; update mergeinfo without actually merging files"
57	"R --recursive; operate on subdirectories recursively"
58	"--reintegrate; merge a branch into the trunk"
59	"--relocate; change the location of the repository"
60	"--remove; remove files from a changelist"
61	"--reverse-diff; patch in reverse"
62	"r: --revision:; specify a revision or a revision range"
63	"--revprop; operate on a revision property rather than a file property"
64	"--set-depth:; specify a new sticky depth of working directories"
65	"--show-copies-as-adds; treat copied files as newly added"
66	"--show-revs:; specify the type of mergeinfo to print"
67	"--show-updates; show which files will be updated by \"svn update\""
68	"--stop-on-copy; operate on revisions after the file was copied last"
69	"--strict; output the raw value without pretty-formatting"
70	"--strip:; specify the number of pathname components to strip from file names"
71	"--summarize; print a summary of changes only"
72	"--targets:; specify a file containing target paths"
73	"g --use-merge-history; use mergeinfo to show history before merges"
74	"v --verbose; print additional info"
75	"--version"
76	"--with-all-revprops; include all revision properties"
77	"--with-no-revprops; include no revision properties"
78	"--with-revprop:; specify a revision property to set or print"
79	"--xml; print in the XML format"
80	) #<#
81	OPTIONS=("$COMMONOPTIONS" "$ADDOPTIONS")
82
83	command -f completion//parseoptions -es
84
85	# find subcommand name
86	typeset SUBCMD= separatorindex=2
87	while [ $separatorindex -lt ${WORDS[#]} ]; do
88		case ${WORDS[separatorindex]} in (--)
89			SUBCMD=${WORDS[separatorindex+1]}
90			break
91		esac
92		separatorindex=$((separatorindex+1))
93	done
94
95	# normalize subcommand name
96	case $SUBCMD in
97		(praise|annotate|ann)
98			SUBCMD=blame;;
99		(cl)
100			SUBCMD=changelist;;
101		(co)
102			SUBCMD=checkout;;
103		(ci)
104			SUBCMD=commit;;
105		(cp)
106			SUBCMD=copy;;
107		(del|remove|rm)
108			SUBCMD=delete;;
109		(di)
110			SUBCMD=diff;;
111		(h|\?)
112			SUBCMD=help;;
113		(ls)
114			SUBCMD=list;;
115		(mv|rename|ren)
116			SUBCMD=move;;
117		(pdel|pd)
118			SUBCMD=propdel;;
119		(pedit|pe)
120			SUBCMD=propedit;;
121		(pget|pg)
122			SUBCMD=propget;;
123		(plist|pl)
124			SUBCMD=proplist;;
125		(pset|ps)
126			SUBCMD=propset;;
127		(stat|st)
128			SUBCMD=status;;
129		(sw)
130			SUBCMD=switch;;
131		(up)
132			SUBCMD=update;;
133	esac
134
135	case $ARGOPT in
136	(-)
137		OPTIONS=("$COMMONOPTIONS")
138		if command -vf "completion/svn::$SUBCMD:opt" >/dev/null 2>&1; then
139			command -f "completion/svn::$SUBCMD:opt"
140		fi
141		command -f completion//completeoptions
142		;;
143	(--accept) #>>#
144		complete -P "$PREFIX" -D "discard all local and remote changes" base
145		complete -P "$PREFIX" -D "discard all remote changes" mine-full
146		complete -P "$PREFIX" -D "resolve conflicts by discarding remote changes" mine-conflict
147		complete -P "$PREFIX" -D "discard all local changes" theirs-full
148		complete -P "$PREFIX" -D "resolve conflicts by discarding local changes" theirs-conflict
149		complete -P "$PREFIX" -D "mark the current working copy as resolved" working
150		case $SUBCMD in
151			(resolve)
152				;;
153			(*)
154				complete -P "$PREFIX" -D "launch an editor to merge by hand" edit
155				complete -P "$PREFIX" -D "launch a predefined external program" launch
156				complete -P "$PREFIX" -D "leave the conflict unresolved" postpone
157				;;
158		esac
159		;; #<<#
160#	(c|--change)
161#		;;
162	(--changelist|--cl)
163		command -f completion/svn::completechangelist
164		;;
165	(--config-dir)
166		complete -P "$PREFIX" -S / -T -d
167		;;
168	(--config-option)
169		#TODO
170		;;
171	(--depth|--set-depth) #>>#
172		complete -P "$PREFIX" -D "only the target itself" empty
173		complete -P "$PREFIX" -D "the target and non-directory immediate children" files
174		complete -P "$PREFIX" -D "the target and immediate children" immediates
175		complete -P "$PREFIX" -D "the target and all of its descendants" infinity
176		#<<#
177		case $ARGOPT in (--set-depth) #>>#
178			complete -P "$PREFIX" -D "exclude the target from the parent" exclude
179		esac #<<#
180		;;
181	(--encoding)
182		#TODO
183		;;
184	(x|--extensions)
185		WORDS=(diff)
186		command -f completion//reexecute
187		;;
188	(F|--file)
189		complete -P "$PREFIX" -f
190		;;
191#	(l|--limit)
192#		;;
193#	(m|--message)
194#		;;
195#	(--password)
196#		;;
197	(--native-eol) #>>#
198		complete -P "$PREFIX" LF CR CRLF
199		;; #<<#
200	(--new|--old)
201		command -f completion/svn::completelocal -cm
202		command -f completion/svn::completeurl
203		;;
204	(r|--revision)
205		typeset word="${TARGETWORD#"$PREFIX"}"
206		PREFIX="${TARGETWORD%"${word#*:}"}"
207		#>>#
208		complete -P "$PREFIX" -D "the latest revision in the repository" HEAD
209		complete -P "$PREFIX" -D "the revision you checked out" BASE
210		complete -P "$PREFIX" -D "the latest revision in which a change was made" COMMITTED
211		complete -P "$PREFIX" -D "the revision immediately before COMMITTED" PREV
212		;; #<<#
213	(--show-revs) #>>#
214		complete -P "$PREFIX" -D "info about merges already performed" merged
215		complete -P "$PREFIX" -D "info about possible merges that can be performed" eligible
216		;; #<<#
217	(--target)
218		complete -P "$PREFIX" -f
219		;;
220	(--username)
221		complete -P "$PREFIX" -u
222		;;
223	(--with-revprop)
224		#TODO
225		;;
226	(--*-cmd)
227		WORDS=()
228		command -f completion//reexecute -e
229		;;
230	('')
231		if [ $separatorindex -eq ${WORDS[#]} ] ||
232				command -f completion/svn::containshelp; then
233			command -f completion/svn::completesubcmd
234		else
235			if command -vf "completion/svn::$SUBCMD:arg" >/dev/null 2>&1; then
236				command -f "completion/svn::$SUBCMD:arg"
237			fi
238		fi
239		;;
240	esac
241
242}
243
244function completion/svn::containshelp {
245	typeset opt
246	for opt in "${WORDS[2,separatorindex-1]}"; do
247		case $opt in (--help|-[h\?])
248			return 0
249		esac
250	done
251	return 1
252}
253
254function completion/svn::setoptions {
255	typeset opt i=1
256	for opt in "$ADDOPTIONS"; do
257		if [ $# -le 0 ]; then
258			break
259		fi
260		case " ${{opt%%;*}//:} " in (*" --$1 "*)
261			OPTIONS=("$OPTIONS" "$opt")
262			shift
263		esac
264	done
265}
266
267function completion/svn::completesubcmd {
268	complete -P "$PREFIX" -D "add files for versioning" add
269	complete -P "$PREFIX" -D "show files with author and revision info" blame praise annotate
270	complete -P "$PREFIX" -D "print the contents of files" cat
271	complete -P "$PREFIX" -D "put files into a changelist" changelist cl
272	complete -P "$PREFIX" -D "check out a working copy from a repository" checkout co
273	complete -P "$PREFIX" -D "resolve file locks and unfinished operations" cleanup
274	complete -P "$PREFIX" -D "make a new revision in the repository" commit ci
275	complete -P "$PREFIX" -D "copy a file" copy cp
276	complete -P "$PREFIX" -D "delete files" delete remove rm
277	complete -P "$PREFIX" -D "print differences between two files or revisions" diff
278	complete -P "$PREFIX" -D "make a copy of the versioned directory tree" export
279	complete -P "$PREFIX" -D "print usage of subcommands" help
280	complete -P "$PREFIX" -D "commit new files into the repository" import
281	complete -P "$PREFIX" -D "print info about versioned files" info
282	complete -P "$PREFIX" -D "print a list of versioned files" list ls
283	complete -P "$PREFIX" -D "lock files in the repository" lock
284	complete -P "$PREFIX" -D "print commit log messages" log
285	complete -P "$PREFIX" -D "apply changes between two files or revisions" merge
286	complete -P "$PREFIX" -D "print info about merge" mergeinfo
287	complete -P "$PREFIX" -D "make directories" mkdir
288	complete -P "$PREFIX" -D "move files" move mv
289	complete -P "$PREFIX" -D "apply a patch" patch
290	complete -P "$PREFIX" -D "delete a property of files" propdel pdel
291	complete -P "$PREFIX" -D "edit a property of files" propedit pedit
292	complete -P "$PREFIX" -D "print a property of files" propget pget
293	complete -P "$PREFIX" -D "print properties of files" proplist plist
294	complete -P "$PREFIX" -D "set a property of files" propset pset
295	complete -P "$PREFIX" -D "change the repository root URL" relocate
296	complete -P "$PREFIX" -D "resolve conflicts" resolve
297	# deprecated: complete -P "$PREFIX" -D "" resolved
298	complete -P "$PREFIX" -D "undo local edits" revert
299	complete -P "$PREFIX" -D "print the status of working copy" status
300	complete -P "$PREFIX" -D "update working copy to a different URL" switch
301	complete -P "$PREFIX" -D "unlock files in the repository" unlock
302	complete -P "$PREFIX" -D "update the working copy" update
303	complete -P "$PREFIX" -D "upgrade the working copy format" upgrade
304}
305
306function completion/svn::completeurl {
307	typeset OPTIND=1 opt dironly=false
308	while getopts d opt; do
309		case $opt in
310			(d) dironly=true;;
311		esac
312	done
313
314	typeset target="${TARGETWORD#"$PREFIX"}"
315	case $target in
316		(?*://* | ^/*) ;;
317		(*)            return ;;
318	esac
319	typeset targetdir="$(dirname -- "$target"X)"
320
321	typeset file prefix="${TARGETWORD%"${TARGETWORD##*/}"}"
322	while read -r file; do
323		case $file in
324			(*/)
325				complete -P "$prefix" -T -- "$file"
326				;;
327			(*)
328				if ! $dironly; then
329					complete -P "$prefix" -- "$file"
330				fi
331				;;
332		esac
333	done <(svn --non-interactive ls -- "${targetdir}/" 2>/dev/null)
334}
335
336function completion/svn::completelocal {
337	typeset OPTIND=1 opt clean= modified= unversioned=
338	while getopts cmu opt; do
339		case $opt in
340			(c) clean=true;;
341			(m) modified=true;;
342			(u) unversioned=true;;
343		esac
344	done
345
346	complete -P "$PREFIX" -S / -T -d
347
348	case "$clean-$modified-$unversioned" in
349		(true-true-true)
350			complete -P "$PREFIX" -f
351			return
352			;;
353		(--)
354			return
355			;;
356	esac
357
358	typeset target="${TARGETWORD#"$PREFIX"}"
359	typeset targetdir="$(dirname -- "$target"X)"
360
361	if ! command -f completion/svn::isworkingdir "$targetdir"; then
362		if [ "$unversioned" ]; then
363			complete -P "$PREFIX" -f
364		fi
365		return
366	fi
367
368	typeset path prefix opt
369	while read -r path; do
370		if [ "$path" -ef "$targetdir" ]; then
371			continue
372		fi
373		case $target in
374			(*/*) prefix="$PREFIX${target%/*}/" ;;
375			(*)   prefix="$PREFIX" ;;
376		esac
377		complete -P "$prefix" -- "${path##*/}"
378	done 2>/dev/null <(
379		if [ "$unversioned" ]; then
380			svn st --depth=files --no-ignore -- "$targetdir" |
381			grep '^[?I]' |
382			cut -c 9-
383		fi
384		if [ "$clean$modified" ]; then
385			case $clean-$modified in
386				(true-true) regex='^[^?I]';;
387				(true-    ) regex='^  ';;
388				(    -true) regex='^[^ ?I]|^.[^ ]';;
389			esac
390			svn st -v --depth=files -- "$targetdir" |
391			grep -E "$regex" |
392			cut -c 10- |
393			while read -r _ _ _ file; do
394				printf '%s\n' "$file"
395			done
396		fi
397	)
398	# XXX should honor the dotglob option
399}
400
401function completion/svn::completepropname { #>>#
402	complete -P "$PREFIX" -D "make the file executable" svn:executable
403	complete -P "$PREFIX" -D "specify the file's MIME type" svn:mime-type
404	complete -P "$PREFIX" -D "specify unversioned filenames not listed in status" svn:ignore
405	complete -P "$PREFIX" -D "specify keywords substituted in file" svn:keywords
406	complete -P "$PREFIX" -D "specify how end-of-line markers are manipulated" svn:eol-style
407	complete -P "$PREFIX" -D "specify external paths and repositories" svn:externals
408	complete -P "$PREFIX" -D "indicate that the file is not a regular file" svn:special
409	complete -P "$PREFIX" -D "disable editing without lock" svn:needs-lock
410	complete -P "$PREFIX" -D "info about merge" svn:mergeinfo
411} #<<#
412
413function completion/svn::completechangelist {
414	typeset changelist
415	while read -r changelist; do
416		changelist=${changelist%\':}
417		changelist=${changelist##*\'}
418		complete -P "$PREFIX" "$changelist"
419	done 2>/dev/null <(svn status | grep "^--- .*'.*':\$")
420}
421
422function completion/svn::isworkingdir (
423	typeset CDPATH= &&
424	cd -P -- "$1" 2>/dev/null &&
425	until [ -d .svn ]; do
426		if [ . -ef .. ] || [ . -ef / ]; then
427			return 1
428		fi
429		cd -P ..
430	done
431)
432
433function completion/svn:::opt {
434	command -f completion/svn::setoptions version
435}
436
437function completion/svn::add:opt {
438	command -f completion/svn::setoptions \
439		auto-props depth force no-auto-props no-ignore parents quiet \
440		targets
441}
442
443function completion/svn::add:arg {
444	command -f completion/svn::completelocal -u
445}
446
447function completion/svn::blame:opt {
448	command -f completion/svn::setoptions \
449		extensions force incremental revision use-merge-history \
450		verbose xml
451}
452
453function completion/svn::blame:arg {
454	command -f completion/svn::completelocal -cm
455	command -f completion/svn::completeurl
456}
457
458function completion/svn::cat:opt {
459	command -f completion/svn::setoptions revision
460}
461
462function completion/svn::cat:arg {
463	command -f completion/svn::completelocal -cm
464	command -f completion/svn::completeurl
465}
466
467function completion/svn::changelist:opt {
468	command -f completion/svn::setoptions \
469		changelist depth quiet recursive remove targets
470}
471
472function completion/svn::changelist:arg {
473	typeset i=2 remove=false
474	while [ $i -lt $separatorindex ]; do
475		case ${WORDS[i]} in
476			(--remove) remove=true;;
477		esac
478		i=$((i+1))
479	done
480	if ! $remove && [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then
481		command -f completion/svn::completechangelist
482	else
483		command -f completion/svn::completelocal -cm
484	fi
485}
486
487function completion/svn::checkout:opt {
488	command -f completion/svn::setoptions \
489		depth force ignore-externals quiet revision
490}
491
492function completion/svn::checkout:arg {
493	command -f completion/svn::completeurl
494	if [ $(($separatorindex+1)) -lt ${WORDS[#]} ]; then
495		complete -P "$PREFIX" -f
496	fi
497}
498
499function completion/svn::cleanup:opt {
500	command -f completion/svn::setoptions diff3-cmd
501}
502
503function completion/svn::cleanup:arg {
504	complete -P "$PREFIX" -S / -T -d
505}
506
507function completion/svn::commit:opt {
508	command -f completion/svn::setoptions \
509		changelist depth editor-cmd encoding file force-log \
510		kee-changelists message no-unlock quiet targets with-revprop
511}
512
513function completion/svn::commit:arg {
514	command -f completion/svn::completelocal -m
515}
516
517function completion/svn::copy:opt {
518	command -f completion/svn::setoptions \
519		editor-cmd encoding file force-log ignore-externals message \
520		parents quiet revision with-revprop
521}
522
523function completion/svn::copy:arg {
524	command -f completion/svn::completelocal -cmu
525	command -f completion/svn::completeurl
526}
527
528function completion/svn::delete:opt {
529	command -f completion/svn::setoptions \
530		editor-cmd encoding file force force-log keep-local \
531		message quiet targets with-revprop
532}
533
534function completion/svn::delete:arg {
535	command -f completion/svn::completelocal -cm
536	command -f completion/svn::completeurl
537}
538
539function completion/svn::diff:opt {
540	command -f completion/svn::setoptions \
541		change changelist depth diff-cmd extensions force git new \
542		no-diff-deleted notice-ancestry old revision \
543		show-copies-as-adds summarize xml
544}
545
546function completion/svn::diff:arg {
547	# XXX should be relative to the argument of --old=...
548	command -f completion/svn::completelocal -cm
549	command -f completion/svn::completeurl
550}
551
552function completion/svn::export:opt {
553	command -f completion/svn::setoptions \
554		depth force ignore-externals native-eol quiet revision
555}
556
557function completion/svn::export:arg {
558	case $((${WORDS[#]} - $separatorindex)) in
559		(1)
560			command -f completion/svn::completelocal -cm
561			command -f completion/svn::completeurl
562			;;
563		(2)
564			complete -P "$PREFIX" -f
565			;;
566	esac
567}
568
569function completion/svn::help:opt {
570}
571
572function completion/svn::help:arg {
573	command -f completion/svn::completesubcmd
574}
575
576function completion/svn::import:opt {
577	command -f completion/svn::setoptions \
578		auto-props depth editor-cmd encoding file force force-log \
579		message no-auto-props no-ignore quiet with-revprop
580}
581
582function completion/svn::import:arg {
583	case $((${WORDS[#]} - $separatorindex)) in
584		(1)
585			command -f completion/svn::completelocal -u
586			;;
587		(2)
588			command -f completion/svn::completeurl
589			;;
590	esac
591}
592
593function completion/svn::info:opt {
594	command -f completion/svn::setoptions \
595		changelist depth incremental recursive revision targets xml
596}
597
598function completion/svn::info:arg {
599	command -f completion/svn::completelocal -cm
600	command -f completion/svn::completeurl
601}
602
603function completion/svn::list:opt {
604	command -f completion/svn::setoptions \
605		depth incremental recursive revision verbose xml
606}
607
608function completion/svn::list:arg {
609	command -f completion/svn::completelocal -cm
610	command -f completion/svn::completeurl
611}
612
613function completion/svn::lock:opt {
614	command -f completion/svn::setoptions \
615		encoding file force force-log message targets
616}
617
618function completion/svn::lock:arg {
619	command -f completion/svn::completelocal -cm
620	command -f completion/svn::completeurl
621}
622
623function completion/svn::log:opt {
624	command -f completion/svn::setoptions \
625		change incremental limit quiet revision stop-on-copy targets \
626		use-merge-history verbose with-all-revprops with-no-revprops \
627		with-revprop xml
628}
629
630function completion/svn::log:arg {
631	command -f completion/svn::completelocal -cm
632	command -f completion/svn::completeurl
633}
634
635function completion/svn::merge:opt {
636	command -f completion/svn::setoptions \
637		accept allow-mixed-revisions change depth diff3-cmd dry-run \
638		extensions force ignore-ancestry quiet record-only reintegrate \
639		revision
640}
641
642function completion/svn::merge:arg {
643	command -f completion/svn::completelocal -cm
644	command -f completion/svn::completeurl
645}
646
647function completion/svn::mergeinfo:opt {
648	command -f completion/svn::setoptions revision show-revs
649}
650
651function completion/svn::mergeinfo:arg {
652	command -f completion/svn::completelocal -cm
653	command -f completion/svn::completeurl
654}
655
656function completion/svn::mkdir:opt {
657	command -f completion/svn::setoptions editor-cmd encoding file \
658		force-log message parents quiet with-revprop
659}
660
661function completion/svn::mkdir:arg {
662	complete -P "$PREFIX" -S / -T -d
663	command -f completion/svn::completeurl -d
664}
665
666function completion/svn::move:opt {
667	command -f completion/svn::setoptions editor-cmd encoding file force \
668		force-log message parents quiet revision with-revprop
669}
670
671function completion/svn::move:arg {
672	command -f completion/svn::completelocal -cm
673	command -f completion/svn::completeurl
674}
675
676function completion/svn::patch:opt {
677	command -f completion/svn::setoptions \
678		dry-run ignore-whitespace quiet reverse-diff strip
679}
680
681function completion/svn::patch:arg {
682	if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then
683		complete -P "$PREFIX" -f
684	else
685		complete -P "$PREFIX" -S / -T -d
686	fi
687}
688
689function completion/svn::propdel:opt {
690	command -f completion/svn::setoptions \
691		changelist depth quiet recursive revision revprop
692}
693
694function completion/svn::propdel:arg {
695	if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then
696		command -f completion/svn::completepropname
697	else
698		command -f completion/svn::completelocal -cm
699		command -f completion/svn::completeurl
700	fi
701}
702
703function completion/svn::propedit:opt {
704	command -f completion/svn::setoptions editor-cmd encoding file force \
705		force-log message revision revprop with-revprop
706}
707
708function completion/svn::propedit:arg {
709	if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then
710		command -f completion/svn::completepropname
711	else
712		command -f completion/svn::completelocal -cm
713		command -f completion/svn::completeurl
714	fi
715}
716
717function completion/svn::propget:opt {
718	command -f completion/svn::setoptions \
719		changelist depth recursive revision revprop strict verbose xml
720}
721
722function completion/svn::propget:arg {
723	if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then
724		command -f completion/svn::completepropname
725	else
726		command -f completion/svn::completelocal -cm
727		command -f completion/svn::completeurl
728	fi
729}
730
731function completion/svn::proplist:opt {
732	command -f completion/svn::setoptions \
733		changelist depth quiet recursive revision revprop verbose xml
734}
735
736function completion/svn::proplist:arg {
737	command -f completion/svn::completelocal -cm
738	command -f completion/svn::completeurl
739}
740
741function completion/svn::propset:opt {
742	command -f completion/svn::setoptions changelist depth encoding file \
743		force quiet recursive revision revprop targets
744}
745
746function completion/svn::propset:arg {
747	typeset i=2 hasfile=false
748	while [ $i -lt $separatorindex ]; do
749		case ${WORDS[i]} in
750			(--file=*|-F*) hasfile=true;;
751		esac
752		i=$((i+1))
753	done
754	if [ $(($separatorindex+1)) -eq ${WORDS[#]} ]; then
755		command -f completion/svn::completepropname
756	elif ! $hasfile && [ $(($separatorindex+2)) -eq ${WORDS[#]} ]; then
757		# there is no completion for a property value
758	else
759		command -f completion/svn::completelocal -cm
760		command -f completion/svn::completeurl
761	fi
762}
763
764function completion/svn::relocate:opt {
765	command -f completion/svn::setoptions ignore-externals
766}
767
768function completion/svn::relocate:arg {
769	command -f completion/svn::switch:arg "$@"
770}
771
772function completion/svn::resolve:opt {
773	command -f completion/svn::setoptions \
774		accept depth quiet recursive targets
775}
776
777function completion/svn::resolve:arg {
778	command -f completion/svn::completelocal -cm
779}
780
781function completion/svn::resolved:opt {
782	command -f completion/svn::setoptions \
783		depth quiet recursive targets
784}
785
786function completion/svn::resolved:arg {
787	command -f completion/svn::completelocal -cm
788}
789
790function completion/svn::revert:opt {
791	command -f completion/svn::setoptions \
792		changelist depth quiet recursive targets
793}
794
795function completion/svn::revert:arg {
796	command -f completion/svn::completelocal -m
797}
798
799function completion/svn::status:opt {
800	command -f completion/svn::setoptions \
801		changelist depth ignore-externals incremental no-ignore quiet \
802		show-updates verbose xml
803}
804
805function completion/svn::status:arg {
806	command -f completion/svn::completelocal -cm
807}
808
809function completion/svn::switch:opt {
810	command -f completion/svn::setoptions \
811		accept depth diff3-cmd force ignore-externals ignore-ancestry \
812		quiet relocate revision set-depth
813}
814
815function completion/svn::switch:arg {
816	if [ $(($separatorindex+1)) -lt ${WORDS[#]} ]; then
817		complete -P "$PREFIX" -S / -T -d
818	fi
819	command -f completion/svn::completeurl
820}
821
822function completion/svn::unlock:opt {
823	command -f completion/svn::setoptions force targets
824}
825
826function completion/svn::unlock:arg {
827	command -f completion/svn::completelocal -cm
828	command -f completion/svn::completeurl
829}
830
831function completion/svn::update:opt {
832	command -f completion/svn::setoptions \
833		accept changelist depth diff3-cmd editor-cmd force \
834		ignore-externals parents quiet revision set-depth
835}
836
837function completion/svn::update:arg {
838	command -f completion/svn::completelocal -cm
839}
840
841function completion/svn::upgrade:opt {
842	command -f completion/svn::setoptions quiet
843}
844
845function completion/svn::upgrade:arg {
846	complete -P "$PREFIX" -S / -T -d
847}
848
849
850# vim: set ft=sh ts=8 sts=8 sw=8 noet:
851