[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] bash_completion: propose file names for few commands

From: Krzysiek Pawlik <nelchael_at_gentoo.org>
Date: 2007-06-03 13:47:33 CEST

Fabien COELHO wrote:
> (0) I like the idea, but it raises issues...

As every idea ;)

> (2) calling 'svn status' on some repositories is a nightmare.
>
> fabien@briare DEV> time svn status
> ... lots of stuff, recursion, external repositories...
> real 0m54.989s
>
> Yes, 55 seconds. No one wants a 55s lag when typing <TAB>.
>
> At the minimum, the --non-recursive option should always be added.
> Moreover, it should also depend on the current completed word,
> so that only the relevant directories are listed?

Attached patch has SVN_EXT_NON_RECURSIVE - if it's set to non empty string
recursion will be disabled.

> (3) I do not like to have "awk" for such very simple stuff.
> use cut instead? Or emulate grep/awk in shell (one loop) ?

awk -> cut done

> (4) minor style issue: lines should be within the 80 column limit.

fixed.

> (5) If costly things are performed on completion, there should
> be a way to disable it (say with an environment variable for
> instance).

The extended completion has to be enabled by setting SVN_EXT_COMPLETION to non
empty value, and see #2.

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...

--- /usr/share/bash-completion/subversion 2007-05-16 11:00:15.000000000 +0200
+++ bin/bash_completion.d/subversion 2007-06-03 13:40:54.000000000 +0200
@@ -1,3 +1,4 @@
+# vim: tw=80
 # Programmable completion for the Subversion svn command under bash. Source
 # this file (or on some systems add it to ~/.bash_completion and start a new
 # shell) and bash's completion mechanism will know all about svn's options!
@@ -420,7 +421,32 @@
 
         # if not typing an option,
         # then fallback on ordinary filename expansion
- if [[ $cur != -* || $stat = 'onlyarg' ]] ; then
+ if [[ -n "${SVN_EXT_COMPLETION}" ]] && [[ $cur != -* || $stat = 'onlyarg' ]]
+ then
+ local nr=
+ [[ -n "${SVN_EXT_NON_RECURSIVE}" ]] && nr="-N"
+ case $cmd in
+ revert)
+ local FILESrevert="$(svn status --non-interactive ${nr} \
+ | grep '^[M!]' | cut -b 8-)"
+ COMPREPLY=( $( compgen -W "$FILESrevert" -- $cur ) )
+ ;;
+ add)
+ local FILESadd="$(svn status --non-interactive ${nr} \
+ | grep '^?' | cut -b 8-)"
+ COMPREPLY=( $( compgen -W "$FILESadd" -- $cur ) )
+ ;;
+ log)
+ local FILESlog="$(svn status --non-interactive -v -N \
+ | cut -b 41-)"
+ COMPREPLY=( $( compgen -W "$FILESlog" -- $cur ) )
+ ;;
+ remove|rm|delete|del)
+ local FILESremove="$(svn status --non-interactive -v -N \
+ | sed -e '1d' | cut -b 41- | grep -v '^\.$')"
+ COMPREPLY=( $( compgen -W "$FILESremove" -- $cur ) )
+ ;;
+ esac
             return 0
         fi
 

Received on Sun Jun 3 13:46:36 2007

This is an archived mail posted to the Subversion Dev mailing list.