Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Bug#512308: zsh: out-of-date completions for svn revert



>>>>> Clint Adams <schizo@xxxxxxxxxx> writes:

> On Mon, Jan 19, 2009 at 03:55:20PM +0100, Vincent Lefevre wrote:
>> Once completions have been done, information for "svn revert"
>> can become out-of-date. Let's see the problem on an example,
>> in an empty working copy:
>> 
>> $ touch blah1
>> $ svn add blah1
>> $ svn revert [TAB]
>> 
>> This one completes to "svn revert blah1" as expected. Type [Enter].
>> 
>> $ touch blah2
>> $ svn add blah2
>> $ svn revert [TAB]
>> 
>> This one completes to "svn revert blah1" again, while it should have
>> completed to "svn revert blah2".

> Is there a timestamp that the 'svn add' will touch so we could compare it
> with the cache age?

Here's a patch to fix this svn completion problem reported back in
January [workers #26367].. things were even worse than it appeared
because the key used for caching 'svn status' output for a directory
was the relative directory path, which would usually be '.' so if you
cd'd around it would have exhibited worse problems.  It's now caching
based on the directory device and inode, and using the mtime of the
.svn/entries file to invalidate a cached entry.

cheers,
Greg

Index: Completion/Unix/Command/_subversion
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_subversion,v
retrieving revision 1.26
diff -u -r1.26 _subversion
--- Completion/Unix/Command/_subversion	17 May 2009 18:23:10 -0000	1.26
+++ Completion/Unix/Command/_subversion	18 May 2009 02:19:15 -0000
@@ -22,7 +22,7 @@
     ;;
     args)
       local cmd args usage
-      typeset -gHA _cache_svn_status
+      typeset -gHA _cache_svn_status _cache_svn_mtime
 
       cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}"
       if (( $#cmd )); then
@@ -193,11 +193,16 @@
   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)"
+  zmodload -F zsh/stat b:zstat 2>/dev/null
+  local key="$(zstat +device $dir):$(zstat +inode $dir)"
+  local mtime="$(zstat +mtime $dir/.svn/entries)"
+
+  if (( ! $+_cache_svn_status[$key] || _cache_svn_mtime[$key] != mtime )); then
+    _cache_svn_status[$key]="$(_call_program files svn status -N $dir)"
+    _cache_svn_mtime[$key]="$mtime"
   fi
 
-  (( ${(M)#${(f)_cache_svn_status[$dir]}:#(#s)${~pat}*$REPLY} ))
+  (( ${(M)#${(f)_cache_svn_status[$key]}:#(#s)${~pat}*$REPLY} ))
 }
 
 (( $+functions[_svn_urls] )) ||


Messages sorted by: Reverse Date, Date, Thread, Author