Vadim Zeitlin | 15 Sep 18:32

svn completion under Cygwin

 Hello,

 My Cygwin zsh 4.3.2 doesn't complete any file names for "svn ci" (and
other svn subcommands) and the problem persists even when using the latest
completion file version from

http://zsh.cvs.sourceforge.net/*checkout*/zsh/zsh/Completion/Unix/Command/_subversion?revision=1.25

I couldn't really understand where exactly does the problem come from to be
honest but, as this works under Unix I was almost sure that it was due to
either "\r\n" line terminators or backslashes instead of slashes in the
output of Win32 svn version. It turned out to be the latter and so the
following trivial patch makes the completion work as expected:

--- _subversion.orig    2008-09-15 18:29:24.788071400 +0200
+++ _subversion 2008-09-15 18:29:33.412740200 +0200
@@ -194,7 +194,7 @@
   local pat="${1:-([ADMR~]|?M)}"

   if (( ! $+_cache_svn_status[$dir] )); then
-    _cache_svn_status[$dir]="$(_call_program files svn status -N $dir)"
+    _cache_svn_status[$dir]="$(_call_program files svn status -N $dir) | tr '\\' '/'"
   fi

   (( ${(M)#${(f)_cache_svn_status[$dir]}:#(#s)${~pat}*$REPLY} ))

This is almost surely not the best way to fix it but maybe this is going to
be useful to somebody. And if anybody could propose a better fix which
could be included in the next versions of zsh it would be great,

(Continue reading)

Peter Stephenson | 16 Sep 11:42
Favicon

Re: svn completion under Cygwin

On Mon, 15 Sep 2008 18:33:25 +0200
Vadim Zeitlin <vz-zsh <at> zeitlins.org> wrote:
>  My Cygwin zsh 4.3.2 doesn't complete any file names for "svn ci" (and
> other svn subcommands) and the problem persists even when using the latest
> completion file version from
> 
> http://zsh.cvs.sourceforge.net/*checkout*/zsh/zsh/Completion/Unix/Command/_subversion?revision=1.25
> 
> I couldn't really understand where exactly does the problem come from to be
> honest but, as this works under Unix I was almost sure that it was due to
> either "\r\n" line terminators or backslashes instead of slashes in the
> output of Win32 svn version. It turned out to be the latter and so the
> following trivial patch makes the completion work as expected:

I think if you open a file the right way in Cygwin it will do this kind of
substitution for you.  We had a related discussion not so long ago.
However, I don't have the time to investigate Cygwin further to find out
how this should work.

--

-- 
Peter Stephenson <pws <at> csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

Vadim Zeitlin | 19 Sep 12:32

Re[2]: svn completion under Cygwin

On Tue, 16 Sep 2008 10:42:40 +0100 Peter Stephenson <pws <at> csr.com> wrote:

PS> On Mon, 15 Sep 2008 18:33:25 +0200
PS> Vadim Zeitlin <vz-zsh <at> zeitlins.org> wrote:
PS> >  My Cygwin zsh 4.3.2 doesn't complete any file names for "svn ci" (and
PS> > other svn subcommands) and the problem persists even when using the latest
PS> > completion file version from
PS> > 
PS> > http://zsh.cvs.sourceforge.net/*checkout*/zsh/zsh/Completion/Unix/Command/_subversion?revision=1.25
PS> > 
PS> > I couldn't really understand where exactly does the problem come from to be
PS> > honest but, as this works under Unix I was almost sure that it was due to
PS> > either "\r\n" line terminators or backslashes instead of slashes in the
PS> > output of Win32 svn version. It turned out to be the latter and so the
PS> > following trivial patch makes the completion work as expected:
PS> 
PS> I think if you open a file the right way in Cygwin it will do this kind of
PS> substitution for you.  We had a related discussion not so long ago.

 Sorry, I couldn't find anything about it at 

	http://www.zsh.org/mla/workers/2008/threads.html

and I also have no idea how to make Cygwin to translate the Windows-style
filenames to POSIX ones automatically (and to be honest would be rather
surprised if it were possible). Could you have meant using cygpath to do
the conversion instead of a simple tr? If so, this could be done, of
course, but then it would need to be only done under Cygwin and I'm not
sure what would be the best way to have a Cygwin-only part of a completion
function, are there already any examples of doing this? I only found
(Continue reading)

Peter Stephenson | 22 Sep 20:23
Favicon

Re: svn completion under Cygwin

On Fri, 19 Sep 2008 12:32:25 +0200
Vadim Zeitlin <vz-zsh <at> zeitlins.org> wrote:
>  Sorry, I couldn't find anything about it at 
> 
> 	http://www.zsh.org/mla/workers/2008/threads.html
> 
> and I also have no idea how to make Cygwin to translate the Windows-style
> filenames to POSIX ones automatically (and to be honest would be rather
> surprised if it were possible). Could you have meant using cygpath to do
> the conversion instead of a simple tr?

No, it's internal to the programme.  We already have the following code,

/**/
mod_export void
cygwin_premain0 (int argc, char **argv, void *myself)
{
    static struct __cygwin_perfile pf[] =
    {
        {"", O_RDONLY | O_TEXT},
        {NULL, 0}
    };
    cygwin_internal (CW_PERFILE, pf);
}

to do something of the kind for some files opened by the shell, but it
apparently doesn't cover everything we might need.  That's all I know on
the subject.

--

-- 
(Continue reading)

Vadim Zeitlin | 23 Sep 00:51

Re[2]: svn completion under Cygwin

On Mon, 22 Sep 2008 19:23:57 +0100 Peter Stephenson <p.w.stephenson <at> ntlworld.com> wrote:

PS> On Fri, 19 Sep 2008 12:32:25 +0200
PS> Vadim Zeitlin <vz-zsh <at> zeitlins.org> wrote:
PS> >  Sorry, I couldn't find anything about it at 
PS> > 
PS> > 	http://www.zsh.org/mla/workers/2008/threads.html
PS> > 
PS> > and I also have no idea how to make Cygwin to translate the Windows-style
PS> > filenames to POSIX ones automatically (and to be honest would be rather
PS> > surprised if it were possible). Could you have meant using cygpath to do
PS> > the conversion instead of a simple tr?
PS> 
PS> No, it's internal to the programme.  We already have the following code,
PS> 
PS> /**/
PS> mod_export void
PS> cygwin_premain0 (int argc, char **argv, void *myself)
PS> {
PS>     static struct __cygwin_perfile pf[] =
PS>     {
PS>         {"", O_RDONLY | O_TEXT},
PS>         {NULL, 0}
PS>     };
PS>     cygwin_internal (CW_PERFILE, pf);
PS> }
PS> 
PS> to do something of the kind for some files opened by the shell, but it
PS> apparently doesn't cover everything we might need.  That's all I know on
PS> the subject.
(Continue reading)

Phil Pennock | 23 Sep 01:36

Re: svn completion under Cygwin

On 2008-09-23 at 00:51 +0200, Vadim Zeitlin wrote:
>  But, once again, the problem with svn completion under Cygwin is *not* due
> to CR LF trouble but to the fact that the native Win32 svn.exe outputs the
> file paths with backslashes and not slashes as the completion code expects.
> Let me repost my trivial patch which fixes the completion for me:

Do you have IPv6 connectivity?  If so, can you please tell me what you
see for the fifth line of output from:
  svn ls http://svn.spodhuis.org/svn/scratch-db/trunk
?

On Unix, the output is:
----------------------------8< cut here >8------------------------------
foo bar/
foo"bar/
foo'bar/
foo-bar/
foo\bar/
foo_bar/
----------------------------8< cut here >8------------------------------

So clearly \ is a valid character in a directory name for svn; I can
update files inside such a directory, etc.

I suspect that we need an _svn_osfixup() filter after the svn command,
where that would, for the Windows OSes (I forget the values of $OSTYPE
there) apply changes.  But before that can be written, what 'foo\bar'
maps to needs to be determined, so that we can reverse it.

> -    _cache_svn_status[$dir]="$(_call_program files svn status -N $dir)"
(Continue reading)

Vadim Zeitlin | 23 Sep 10:28

Re[2]: svn completion under Cygwin

On Mon, 22 Sep 2008 16:36:55 -0700 Phil Pennock <zsh-workers+phil.pennock <at> spodhuis.org> wrote:

PP> On 2008-09-23 at 00:51 +0200, Vadim Zeitlin wrote:
PP> >  But, once again, the problem with svn completion under Cygwin is not due
PP> > to CR LF trouble but to the fact that the native Win32 svn.exe outputs the
PP> > file paths with backslashes and not slashes as the completion code expects.
PP> > Let me repost my trivial patch which fixes the completion for me:
PP> 
PP> Do you have IPv6 connectivity?  If so, can you please tell me what you
PP> see for the fifth line of output from:
PP>   svn ls http://svn.spodhuis.org/svn/scratch-db/trunk
PP> ?

 No, sorry, I don't, but I do have my own svn server so I just created a
repository with the files with the same names and the output of "svn ls" is
the same under Windows, i.e. it still uses slashes to indicate directories
in this case, i.e.

	% svn ls svn+ssh://my-server/test
	sub\dir/

So I decided to check how would it work when checked out locally. But this
test failed:

	% svn co svn+ssh://my-server/test
	---------------------------
	svn.exe - Application Error
	---------------------------
	The exception unknown software exception (0xc00000fd) occurred in
	the application at location 0x7c8302d9.
(Continue reading)

Phil Pennock | 23 Sep 17:08

Re: svn completion under Cygwin

On 2008-09-23 at 10:28 +0200, Vadim Zeitlin wrote:
> On Mon, 22 Sep 2008 16:36:55 -0700 Phil Pennock <zsh-workers+phil.pennock <at> spodhuis.org> wrote:
> PP> I suspect that we need an _svn_osfixup() filter after the svn command,
> PP> where that would, for the Windows OSes (I forget the values of $OSTYPE
> PP> there) apply changes.  But before that can be written, what 'foo\bar'
> PP> maps to needs to be determined, so that we can reverse it.
> 
>  I agree in theory but in practice it looks rather unlikely that anybody
> uses backslash in their file names...

Well, nobody using Windows, anyway.  ;-)

So,
case $OSTYPE in
  (...) function _svn_osfixup { tr '\\' '/' } ;;
  (*) function _svn_osfixup { cat } ;;
esac

_cache_svn_status[$dir]="$(_call_program files svn status -N $dir | _svn_osfixup)"

where ... should be whatever $OSTYPE is on Windows, or the list of such
types.

Make sense?

-Phil

Vadim Zeitlin | 23 Sep 18:18

Re[2]: svn completion under Cygwin

On Tue, 23 Sep 2008 08:08:11 -0700 Phil Pennock <zsh-workers+phil.pennock <at> spodhuis.org> wrote:

PP> Well, nobody using Windows, anyway.  ;-)

 Well, Cygwin is almost Unix :-/

PP> So,
PP> case $OSTYPE in
PP>   (...) function _svn_osfixup { tr '\\' '/' } ;;

 s/.../cygwin/ -- at least this is OSTYPE value here.

PP>   (*) function _svn_osfixup { cat } ;;
PP> esac
PP> 
PP> _cache_svn_status[$dir]="$(_call_program files svn status -N $dir | _svn_osfixup)"
PP> 
PP> where ... should be whatever $OSTYPE is on Windows, or the list of such
PP> types.
PP> 
PP> Make sense?

 Yes, perfectly. I guess it could be nice to get rid of an extra unneeded
pipe to cat under normal systems but I don't see any nice way to do it (the
obvious one would define a variable which would be either empty or contain
"| tr '\\' '/'" but this would require an eval).

 Thanks,
VZ
(Continue reading)

Peter Stephenson | 23 Sep 10:28
Favicon

Re: Re[2]: svn completion under Cygwin

Vadim Zeitlin wrote:
>  I'm afraid I'm missing something obvious but does this really have
> anything to do with replacing backslashes with slashes?

You're quite right, I'm talking about something else entirely.

--

-- 
Peter Stephenson <pws <at> csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


Gmane