You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Norbert Unterberg <ne...@gmx.net> on 2004/07/31 08:35:04 UTC

Recursive client operations not intuitive

I (as a user) have problem with the sematics of the recursive client
operations. In my opinion they do not work as a "normal" user might expect.
However, I can only speak for the DOS/Windows world, I don't know about the
typical recursive semantic under the *x operating systems.

I am used to the behaviour that I can use both a wildcard mask and the
recursive operations. They do not exclude each other. When I do a 

	dir /s /b *.txt

in a windows command line the command lists all text files in all
subdirectories:

	D:\test>dir /s /b *.txt
	D:\test\test1.txt
	D:\test\test2.txt
	D:\test\dir\test1.txt
	D:\test\dir\test2.txt

(/s is the CMD equivalent to -R, and /b is to display as simple file list)  

When I do the same with svn, the -R does not seem to work:

	D:\test>svn ls -R *.txt
	test1.txt
	test2.txt

Where is the recursive operation? Replace the ls with proset, info or
whatever svn subcommand you like, they seem to behave the same in this
respect. 

Ok, I have now learned that recursive operations only work on the exact
target you specify, not on the target wildcard mask in the current direcotry
and it's descendents. Since *.txt does not specify a directory, the svn
operation only works _on_ *.txt, and the -R does not have any meaning. It
gets worse if you actually have a directory named dir.txt. If I run 
	svn propset -R svn:eol-style native *.txt
This command sets the property on all *.txt files in the current directory,
and on all *.txt files in *.txt directories.

Is that really what a typical user would expect from -R? What is the typical
use of -R as you have designed it?

There will be some users who might reply "Hey, you could always write a
script to do that" or "Why don't you use 'find -blah *.txt | xargs
-someoption svn dosomething *.txt'". But what does svn have the -R for, when
it does not work on files recursively? I have the feeling that many usages
of -R would make sense on files, like

   svn propset -R svn:eof-style native *.c *.h

to set a property in the complete project directory

What do you think?

Sorry for stealing your time

Norbert 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: Recursive client operations not intuitive

Posted by Thilo-Alexander Ginkel <ma...@tgbyte.com>.
Branko Cibej wrote:

> Maybe I should elaborate a bit here. There _is_ a difference between
> Unix and Windows with regard to argument expansion: on Unix, you can 
> tell the shell not to expand wildcards by using appropriate quoting. 
> That won't work on Windows, because the C runtime's wildcard expansion 
> ignores quotes

I don't think this is correct. From the Visual C++ documentation:

-- 8< --
Command-line arguments are handled by a routine called _setargv (or
_wsetargv in the wide-character environment), which by default does
not expand wildcards into separate strings in the argv string array.
You can replace the normal _setargv routine with a more powerful
version of _setargv that does handle wildcards by linking with the
Setargv.obj file. [...]

The wildcards are expanded in the same manner as operating system
commands. [...] Enclosing an argument in double quotation marks (" ")
suppresses the wildcard expansion. Within quoted arguments, you can
represent quotation marks literally by preceding the double-quotation-
mark character with a backslash (\). If no matches are found for the
wildcard argument, the argument is passed literally.
-- 8< --

Regards,
Thilo


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Branko Čibej <br...@xbc.nu>.
Branko Čibej wrote:

> Norbert Unterberg wrote:
>
>> Subversion already behaves different in this respect, I belive. On 
>> Unix, the wildcards are expanded very early during processing (by the 
>> shell). That means the wildcard will not be applied on files in 
>> subdirecotries. On Windows, on the other hand, the wildcards seem to 
>> expand in a very late state, while walking recursively through the 
>> directory tree.
>>
> No. On Windows, the wildcards are expanded by the C runtime library 
> before main() is called, so the net effect is the same as if the shell 
> had expanded them.

Maybe I should elaborate a bit here. There _is_ a difference between 
Unix and Windows with regard to argument expansion: on Unix, you can 
tell the shell not to expand wildcards by using appropriate quoting. 
That won't work on Windows, because the C runtime's wildcard expansion 
ignores quotes -- and anyway, the Windows shell only recognises one kind 
of quote -- unlike Unix shells that tend to use about 15 different 
quoting styles, with roughtly 42 different meanings, depending on how 
you combine them. :-)

-- Brane


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Roel Harbers <ro...@roelharbers.nl>.
Branko Čibej wrote:

> Of course, any attempt by Subversion to expand wildcards internally 
> would interact with the shell's wildcard expansion, and would cause all 
> sorts of problems with filenames that legitimately contain wildcard 
> characters...

*shiver*

That reminds of the guy here that likes to put all sorts of smileys in 
his (windows) filenames.

Regards,

Roel Harbers


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Branko Čibej <br...@xbc.nu>.
Norbert Unterberg wrote:

>To summarize: From my (windows biased) point of view, I think the way svn 
>currently handles wildcards and recursion is not optimal.
>
I agree, and I don't think this is specific to Windows. At least, any 
use of wildcards with -R is unintuitive; the user expects SVN to expand 
the wildcards in each subdirectory, when in fact it does not.

Of course, any attempt by Subversion to expand wildcards internally 
would interact with the shell's wildcard expansion, and would cause all 
sorts of problems with filenames that legitimately contain wildcard 
characters...


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Norbert Unterberg <ne...@gmx.net>.
Branko Čibej <brane <at> xbc.nu> writes:

> > In this case they are used to filter 
> >file names within subdirectories, too.
>
> I'd like to see proof of that. I don't believe it.

I have to apologise. 

I have created a small test case and tried to verify all this again. You are 
right, the wildcards are not expanded within subdirectories. However, I find the 
behaviour still some kind of weird, but it is beginning to make sense to me.

This is an example script:

svn mkdir test
cd test
svn mkdir dir.txt
echo test1 > test1.txt
echo test1 > test1.bla
echo test2 > dir.txt\test2.txt
echo test2 > dir.txt\test2.bla
svn add *.*
svn add dir.txt\*.*
svn ci -m "test dir"

This creates a demo directory structure, where "svn ls -R" reports
dir.txt/
dir.txt/test2.bla
dir.txt/test2.txt
test1.bla
test1.txt

Try this: "svn ls"
dir.txt/
test1.bla
test1.txt

But now "svn ls *.txt" and "svn ls -R *.txt" both do this:
test2.bla
test2.txt
test1.txt

Without understanding svn internals, I would have expexted 
"svn ls *.txt"
   dir.txt/
   test1.txt
because a "dir /b *.txt" also gives me 
   dir.txt
   test1.txt

and "svn ls -R *.txt"
   dir.txt/    (<-- we can talk about this one...)
   dir.txt/test2.txt
   test1.txt

as does "dir /s/b *.txt"
   dir.txt
   test1.txt
   dir.txt\test2.txt

Ok lets stop here, I think I am might be starting to count beans ...

I want to go back to the original topic. When I want to perform an operation on 
my project tree, I usally want to perform the operation either on a set of files 
(like removing *.bak in all directories), or on a set of directories (like 
setting the property svn:ignore). Both operations are recursive. I for myself 
dustinguish clearly if the operation is targeting a set of directories or files. 
But I have no way telling svn the target type. svn allows recursive operations 
on single files (not complaining about -R when target is a file), and it 
operates also on files when my intent is to work recursively only on directores. 
svn only distiguishes files from directories in a very implicit way, like not 
setting an svn:ignore property on a file. The only thing the user can do is not 
to name dirctories and files the same way (which is not always possible due to 
rules of some development systems).

To summarize: From my (windows biased) point of view, I think the way svn 
currently handles wildcards and recursion is not optimal. It is your decision if 
this is the correct and planned behaviour, or if this is an issue that might be 
improved. I can live with it now I think I have understood. 

How about some additional sentences in the manual, something like this:

--recursive (-R)
Makes a subcommand recurse into subdirectories, only if the target is a 
directory. Ignored if the target is a file. Care must be taken if the target is 
a wildcard that matches directories and files because the subcommand is applied 
to all matching files and directories individually.
Most subcommands recurse by default.

Norbert



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Branko Čibej <br...@xbc.nu>.
Norbert Unterberg wrote:

>Greg Hudson <ghudson <at> MIT.EDU> writes:
>
>  
>
>>Well, on Unix, Subversion doesn't even see the "*.txt"; the shell
>>expands it, and Subversion sees just test1.txt and test2.txt.
>>
>>[...] but only at the expense of making Subversion behave
>>differently across platforms.
>>    
>>
>
>Subversion already behaves different in this respect, I belive. On Unix, the 
>wildcards are expanded very early during processing (by the shell). That means 
>the wildcard will not be applied on files in subdirecotries. On Windows, on the 
>other hand, the wildcards seem to expand in a very late state, while walking 
>recursively through the directory tree.
>
No. On Windows, the wildcards are expanded by the C runtime library 
before main() is called, so the net effect is the same as if the shell 
had expanded them.

> In this case they are used to filter 
>file names within subdirectories, too.
>  
>
I'd like to see proof of that. I don't believe it.

-- Brane


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Norbert Unterberg <ne...@gmx.net>.
Greg Hudson <ghudson <at> MIT.EDU> writes:

> Well, on Unix, Subversion doesn't even see the "*.txt"; the shell
> expands it, and Subversion sees just test1.txt and test2.txt.
> 
> [...] but only at the expense of making Subversion behave
> differently across platforms.

Subversion already behaves different in this respect, I belive. On Unix, the 
wildcards are expanded very early during processing (by the shell). That means 
the wildcard will not be applied on files in subdirecotries. On Windows, on the 
other hand, the wildcards seem to expand in a very late state, while walking 
recursively through the directory tree. In this case they are used to filter 
file names within subdirectories, too.

That means the same 
   svn propset -R <propname> <value> <wildcard>
command will right now set the property on a different set of files (depending 
on the OS), if <wildcard> describes a pattern that matches files and 
directories.

Is that true or am I on a wrong track here? I am still a svn beginner.

Norbert



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Recursive client operations not intuitive

Posted by Greg Hudson <gh...@MIT.EDU>.
On Sat, 2004-07-31 at 04:35, Norbert Unterberg wrote:
> 	D:\test>svn ls -R *.txt

Well, on Unix, Subversion doesn't even see the "*.txt"; the shell
expands it, and Subversion sees just test1.txt and test2.txt.

So there would (presumably) be the potential under Windows to expand
wildcards in a manner more consistent with DOS recursive wildcard
expansion, but only at the expense of making Subversion behave
differently across platforms.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org