Return-Path: X-Original-To: apmail-subversion-dev-archive@minotaur.apache.org Delivered-To: apmail-subversion-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3446018A48 for ; Tue, 18 Aug 2015 12:21:19 +0000 (UTC) Received: (qmail 37445 invoked by uid 500); 18 Aug 2015 12:21:18 -0000 Delivered-To: apmail-subversion-dev-archive@subversion.apache.org Received: (qmail 37391 invoked by uid 500); 18 Aug 2015 12:21:18 -0000 Mailing-List: contact dev-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@subversion.apache.org Received: (qmail 37381 invoked by uid 99); 18 Aug 2015 12:21:18 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Aug 2015 12:21:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id F26651AA68C for ; Tue, 18 Aug 2015 12:21:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=6.31 tests=[URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id X8SyP4mFDyUy for ; Tue, 18 Aug 2015 12:21:10 +0000 (UTC) Received: from mail.m-otion.at (mail.m-otion.at [213.164.4.99]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 24CF242B21 for ; Tue, 18 Aug 2015 12:21:10 +0000 (UTC) Received: from 91-119-134-134.dynamic.xdsl-line.inode.at ([91.119.134.134] helo=chris-pc.localnet) by mail.m-otion.at with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1ZRft0-0007sW-48; Tue, 18 Aug 2015 14:21:02 +0200 From: Christian Ferbar To: Julian Foad Cc: dev Subject: Re: bash_completion - subversion add: svn ls/merge ^/ Date: Tue, 18 Aug 2015 14:20:56 +0200 Message-ID: <5738538.WDV6EqNOyy@chris-pc> Organization: qnipp GmbH User-Agent: KMail/4.14.9 (Linux/3.16.7-21-desktop; KDE/4.14.9; x86_64; ; ) In-Reply-To: References: <3421020.HomHkagcjs@chris-ws> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart7348313.5v8vXPmayz" Content-Transfer-Encoding: 7Bit This is a multi-part message in MIME format. --nextPart7348313.5v8vXPmayz Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi, new version. This patch are my current changes for "svn ls" only. I need some feedback concerning: -> how to deal with svn error messages written to stderr, for example: svn ls svn+ssh://svn.something.com/user@svn.something.com's password: this happens when you forget to do ssh-add -> in bash >= 4 they changed COMP_WORDS. The Line will be split at : as well, so "file:/something" are 3 array items. Nobody would use subversion 1.9 with bash 3 ... probably. I will drop bash 3 statements, for example: if [[ $cur == file:* ]] ok? > Please can URL completion work on full URLs as well as on relative URLs? for SVN LS this is done: 1. svn ls tabtab -> ^/ file:/// http:// https:// svn:// svn+ssh:// 2. svn ls svn+ssh://tabtab -> will look at the ~/.ssh/known_hosts 3. svn ls http[s]://tabtab -> lookup in ~/.subversion/simple-auth - should still be working 4. svn ls proto://server/tabtab or ^/tabtab -> autocomplete via "svn ls" cheers, Chris --nextPart7348313.5v8vXPmayz Content-Disposition: attachment; filename="bash_completion_subversion.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="bash_completion_subversion.patch" Index: bash_completion =================================================================== --- bash_completion (Revision 1696324) +++ bash_completion (Arbeitskopie) @@ -204,7 +204,7 @@ propCmds="$psCmds|propget|pget|pg|propedit|pedit|pe|propdel|pdel|pd" # possible URL schemas to access a subversion server - local urlSchemas='file:/// http:// https:// svn:// svn+ssh://' + local urlSchemas='^/ file:/// http:// https:// svn:// svn+ssh://' # Parse arguments and set various variables about what was found. # @@ -392,16 +392,37 @@ if [[ $cmd == @(co|checkout|ls|list) && $stat = 'arg' && \ $SVN_BASH_COMPL_EXT == *urls* ]] then + # echo "daaa [$cur] [$1] [$2] [$3] [$4] | [${COMP_WORDS[@]}] [$COMP_WORDBREAKS]" + local prefix=${COMP_WORDS[COMP_CWORD-2]} # see about COMP_WORDBREAKS workaround in prop completion - if [[ $cur == file:* ]] + if [[ $prefix == "file" && "$3" == ":" ]] then # file completion for file:// urls - local where=${cur/file:/} + local where=$cur COMPREPLY=( $(compgen -d -S '/' -X '*/.*' -- $where ) ) return - elif [[ $cur == *:* ]] + elif [[ ( $cmd == @(ls|list) && $cur == ^/* ) || ( "$3" == ":" && $cur == //*/* ) ]] + then # autocomplete for svn ls ^/bla | svn ls remote_url | svn checkout remote_url + local p + if [ "$3" == ":" ] ; then + p="$prefix$3" + fi + if [[ $cur =~ ((.*/)([^/]*)) ]] # url = everything up to the last / + then + local url="${BASH_REMATCH[2]}" + local path="${BASH_REMATCH[3]}" + local remote_files="$(svn ls "$p$url")" + # echo "$remote_files" + COMPREPLY=( $(compgen -P "$url" -W "$remote_files" -- "$path" ) ) + compopt -o nospace + return 0 + fi + # bash 3: elif [[ $cur == *:* ]] + # bash 4: + elif [[ "$3" == ":" ]] then - # get known urls + # echo "search known urls" + # get known server - urls local urls= file= for file in ~/.subversion/auth/svn.simple/* ; do if [ -r $file ] ; then @@ -413,12 +434,23 @@ done # only suggest/show possible suffixes - local prefix=${cur%:*} suffix=${cur#*:} c= choices= + local suffix=$cur c= choices= + #echo "####$prefix####" for c in $urls ; do [[ $c == $prefix:* ]] && choices="$choices ${c#*:}" done - - COMPREPLY=( $(compgen -W "$choices" -- $suffix ) ) + #echo "----$choices----" + + # svn+ssh:// + if [[ $prefix == "svn+ssh" && $cur =~ (^//(.*)) ]] ; then + local server_start=${BASH_REMATCH[2]} + # debian & suse: /usr/share/bash-completion/bash_completion + _known_hosts_real -p // "$server_start" + # echo "~$server_start~~~~~${COMPREPLY[@]}" + else + COMPREPLY=( $(compgen -W "$choices" -- $suffix ) ) + fi + compopt -o nospace return else # show schemas @@ -426,6 +458,7 @@ compopt -o nospace return fi + #echo "nothing found" fi if [[ $cmd = 'merge' || $cmd = 'mergeinfo' ]] @@ -454,6 +487,16 @@ # force --reintegrate only if the current word is empty COMPREPLY=( $(compgen -W '--reintegrate' -- $cur ) ) return 0 + elif [[ $URL == ^/* ]] ; then + # autocomplete for svn merge ^/bla + if [[ $cur =~ ((.*/)([^/]*)) ]] ; then + local url="${BASH_REMATCH[2]}" + local path="${BASH_REMATCH[3]}" + local remote_files="$(svn ls "$url")" + COMPREPLY=( $(compgen -P "$url" -W "$remote_files" -- "$path" ) ) + compopt -o nospace + return 0 + fi fi fi --nextPart7348313.5v8vXPmayz--