zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@sunsite.dk
Cc: Vincent Lefevre <vincent@vinc17.org>, 512308-forwarded@bugs.debian.org
Subject: PATCH: Re: Bug#512308: zsh: out-of-date completions for svn revert
Date: Sun, 17 May 2009 22:34:01 -0400	[thread overview]
Message-ID: <m3skj3qgva.fsf_-_@klanderman.net> (raw)
In-Reply-To: <20090119150602.GA3752@scru.org> (Clint Adams's message of "Mon, 19 Jan 2009 15:06:02 +0000")

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]


>>>>> Clint Adams <schizo@debian.org> 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


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1361 bytes --]

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] )) ||

  parent reply	other threads:[~2009-05-18  2:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090119145520.GA29602@vin.lip.ens-lyon.fr>
2009-01-19 15:06 ` Clint Adams
2009-01-20  1:28   ` Vincent Lefevre
2009-01-23  2:17     ` Clint Adams
2009-05-18  2:34   ` Greg Klanderman [this message]
2009-05-21  7:56     ` PATCH: " Vincent Lefevre
2009-05-22 15:42       ` Greg Klanderman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3skj3qgva.fsf_-_@klanderman.net \
    --to=gak@klanderman.net \
    --cc=512308-forwarded@bugs.debian.org \
    --cc=vincent@vinc17.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).