zsh-workers
 help / color / mirror / code / Atom feed
* Re: Bug#299950: zsh: Better completion for "svn revert"
       [not found]   ` <20050325161734.GT19392@ay.vinc17.org>
@ 2005-03-27  0:36     ` Clint Adams
  2005-03-31  1:02       ` Vincent Lefevre
  2005-03-31 14:17       ` Oliver Kiddle
  0 siblings, 2 replies; 3+ messages in thread
From: Clint Adams @ 2005-03-27  0:36 UTC (permalink / raw)
  To: zsh-workers; +Cc: Vincent Lefevre, 299950-forwarded

> This wouldn't be sufficient. In the first column, this would be at
> least 'A', 'D' (note that the file no longer exists, but completion
> should be able to give the deleted file) and 'M'. In the second
> column, this would be 'M'.

I'm not sure I understand.  Does this patch make it do the right thing?

Index: Completion/Unix/Command/_subversion
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_subversion,v
retrieving revision 1.8
diff -u -r1.8 _subversion
--- Completion/Unix/Command/_subversion	23 Jan 2005 19:56:09 -0000	1.8
+++ Completion/Unix/Command/_subversion	27 Mar 2005 00:32:18 -0000
@@ -21,6 +21,11 @@
   [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]]
 }
 
+(( $+functions[_svn_adm_files] )) ||
+_svn_adm_files() {
+  compadd ${${(M)${(f)"$(svn status)"}:#(#s)[ADM]*}##[ADM] ##}
+}
+
 (( $+functions[_svn_urls] )) ||
 _svn_urls() {
   local expl
@@ -82,6 +87,11 @@
 	'*:file:_files -g "*(e:_svn_controlled:)"'
       )
     ;;
+    (revert)
+      _svn_subcmds+=(
+	'*:file:_svn_adm_files'
+      )
+    ;;
     *)
       case $_svn_subcmd_usage in
         *(SRC|DST|TARGET|URL*PATH)*)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug#299950: zsh: Better completion for "svn revert"
  2005-03-27  0:36     ` Bug#299950: zsh: Better completion for "svn revert" Clint Adams
@ 2005-03-31  1:02       ` Vincent Lefevre
  2005-03-31 14:17       ` Oliver Kiddle
  1 sibling, 0 replies; 3+ messages in thread
From: Vincent Lefevre @ 2005-03-31  1:02 UTC (permalink / raw)
  To: zsh-workers, 299950-forwarded

On 2005-03-26 19:36:52 -0500, Clint Adams wrote:
> +(( $+functions[_svn_adm_files] )) ||
> +_svn_adm_files() {
> +  compadd ${${(M)${(f)"$(svn status)"}:#(#s)[ADM]*}##[ADM] ##}

Doing a recursive "svn status" is not a good idea, as it may take
a very long time. I suggest doing a "svn -N status" and completing
also on any directory containing a .svn subdirectory.

Moreover, the [ADM] pattern is incorrect. It should be ([ADM]|?M).
This would give:

  compadd ${${(M)${(f)"$(svn -N status)"}:#(#s)([ADM]|?M)*}##([ADM]|?M) ##}

+ the code to complete on directories (only those that contain a
.svn subdirectory, in fact).

When one tries to complete on

  svn revert path/to/dir/

zsh should do a "svn -N status path/to/dir", which returns lines like

A     path/to/dir/added_file
D     path/to/dir/deleted_file
M     path/to/dir/modified_file
 M    path/to/dir/modifprop_file

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug#299950: zsh: Better completion for "svn revert"
  2005-03-27  0:36     ` Bug#299950: zsh: Better completion for "svn revert" Clint Adams
  2005-03-31  1:02       ` Vincent Lefevre
@ 2005-03-31 14:17       ` Oliver Kiddle
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Kiddle @ 2005-03-31 14:17 UTC (permalink / raw)
  To: zsh-workers, Vincent Lefevre, 299950-forwarded

On 26 Mar, Clint wrote:
> > This wouldn't be sufficient. In the first column, this would be at
> > least 'A', 'D' (note that the file no longer exists, but completion
> > should be able to give the deleted file) and 'M'. In the second
> > column, this would be 'M'.
> 
> I'm not sure I understand.  Does this patch make it do the right thing?

In addition to the points made by Vincent, it is also better to use
_files instead of rewriting filename completion. If you need complicated
rules to decide which files to include then use a function with the e
glob qualifier. This is what _svn_controlled does to pick up files under
configuration control. The result is that the file-patterns style and
many other nice features of _files/_path_files will work.

The following patch adds two new functions: _svn_deletedfiles and
_svn_status for use with the e qualifier.

_svn_status checks files against the output of svn status. By default it
picks up modified and added files.

Of course _files doesn't complete files which don't already exist.
_svn_deletedfiles uses a trick I've never tried before with _files: it
fills up the reply array. Usage is along the lines of:
  _files -g '.svn(/e:_svn_deletedfiles:)'
This seems to work quite nicely but I won't be suprised if some problems
arrise. It'll be interesting to see. Only thing I've seen is that they
don't get a space suffix.

Oliver

Index: Completion/Unix/Command/_subversion
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_subversion,v
retrieving revision 1.9
diff -u -r1.9 _subversion
--- Completion/Unix/Command/_subversion	27 Mar 2005 00:41:00 -0000	1.9
+++ Completion/Unix/Command/_subversion	31 Mar 2005 14:13:34 -0000
@@ -21,9 +21,28 @@
   [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]]
 }
 
-(( $+functions[_svn_adm_files] )) ||
-_svn_adm_files() {
-  compadd ${${(M)${(f)"$(svn status)"}:#(#s)[ADM]*}##[ADM] ##}
+(( $+functions[_svn_deletedfiles] )) ||
+_svn_deletedfiles() {
+  # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)' 
+  local cont controlled
+  reply=( )
+  [[ $REPLY = (*/|).svn ]] || return
+  controlled=( $REPLY/text-base/*.svn-base(N:r:t) )
+  for cont in ${controlled}; do
+    [[ -e $REPLY:h/$cont ]] || reply+=( ${REPLY%.svn}$cont )
+  done
+}
+
+(( $+functions[_svn_status] )) ||
+_svn_status() {
+  local dir=$REPLY:h
+  local pat="${1:-([ADMR]|?M)}"
+
+  if (( ! $+_cache_svn_status[$dir] )); then
+    _cache_svn_status[$dir]="$(_call_program files svn status -N $dir)"
+  fi
+
+  (( ${(M)#${(f)_cache_svn_status[$dir]}:#(#s)${~pat}*$REPLY} ))
 }
 
 (( $+functions[_svn_urls] )) ||
@@ -68,6 +87,7 @@
 (( $+functions[_svn_subcommand] )) ||
 _svn_subcommand () {
   local subcmd _svn_subcmds _svn_subcmd_usage
+  typeset -A _cache_svn_status
 
   _svn_subcmd_usage=${${(M)${(f)"$(LC_MESSAGES=C _call_program options svn help $1)"}:#usage:*}#usage: $1 }
 
@@ -87,9 +107,14 @@
 	'*:file:_files -g "*(e:_svn_controlled:)"'
       )
     ;;
-    (revert)
+    delete)
+      _svn_subcmds+=(
+        '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"'
+      )
+    ;;
+    revert|commit)
       _svn_subcmds+=(
-	'*:file:_svn_adm_files'
+        '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"'
       )
     ;;
     *)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-31 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20050317142638.GA23797@dixsept.loria.fr>
     [not found] ` <20050325142839.GA32333@scowler.net>
     [not found]   ` <20050325161734.GT19392@ay.vinc17.org>
2005-03-27  0:36     ` Bug#299950: zsh: Better completion for "svn revert" Clint Adams
2005-03-31  1:02       ` Vincent Lefevre
2005-03-31 14:17       ` Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).