You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Steve Cohen <sc...@javactivity.org> on 2010/12/01 18:29:58 UTC

svn:ignore with recursive and non-recursive patterns

I have a need to define a number of svn:ignore patterns in my project.

Some are specific directories somewhere in my project tree.  Others are 
particular file types created by a build process such as *.o which may 
be found in any number of  directories.

However, the svn propset command only allows the recursive -R switch to 
be applied to the entire set of values for the svn:ignore property. 
Whereas what is needed is to be able to apply the recursive switch to 
the VALUE(e.g. *.o), not the KEY (e.g. svn:ignore).  Is there any way of 
achieving this?  There doesn't appear to be one.  Yet without it, 
svn:ignore is useless, or at least too cumbersome to be used well.

Steve Cohen

Re: svn:ignore with recursive and non-recursive patterns

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Dec 1, 2010, at 12:29, Steve Cohen wrote:

> I have a need to define a number of svn:ignore patterns in my project.
> 
> Some are specific directories somewhere in my project tree.  Others are particular file types created by a build process such as *.o which may be found in any number of  directories.
> 
> However, the svn propset command only allows the recursive -R switch to be applied to the entire set of values for the svn:ignore property. Whereas what is needed is to be able to apply the recursive switch to the VALUE(e.g. *.o), not the KEY (e.g. svn:ignore).  Is there any way of achieving this?  There doesn't appear to be one.  Yet without it, svn:ignore is useless, or at least too cumbersome to be used well.

svn:ignore is not useless; it works fine, but doesn't have the feature you're looking for.

However, you can set "*.o" in your global-ignores in your Subversion config file; in fact it should already be there unless you've changed it.



Re: svn:ignore with recursive and non-recursive patterns

Posted by Steve Cohen <sc...@javactivity.org>.
On 12/02/2010 10:23 AM, Steve Cohen wrote:
> On 12/01/2010 12:29 PM, Steve Cohen wrote:
>> I have a need to define a number of svn:ignore patterns in my project.
>>
>> Some are specific directories somewhere in my project tree. Others are
>> particular file types created by a build process such as *.o which may
>> be found in any number of directories.
>>
>> However, the svn propset command only allows the recursive -R switch to
>> be applied to the entire set of values for the svn:ignore property.
>> Whereas what is needed is to be able to apply the recursive switch to
>> the VALUE(e.g. *.o), not the KEY (e.g. svn:ignore). Is there any way of
>> achieving this? There doesn't appear to be one. Yet without it,
>> svn:ignore is useless, or at least too cumbersome to be used well.
>>
>> Steve Cohen
>>
>>
> The following methodology seems to work pretty well in my case:
>
> Check out the pristine source TWICE into two local working copies.
>
> One one working copy perform the complete build.
>
> Against that working copy run a python script based on os.walk that
> looks for
> a. executable files
> b. other generated files of interest
> c. newly created directories.
>
> for each a or b found, use the python subprocess module to invoke svn
> propget on the mirror of that directory in the second working copy. This
> is necessary because, svn update and svn commit do not work on a
> directory tree containing unversioned directories. Check to make sure
> that the object is not already in the properties, and if not, add it to
> the list and save it with svn propset.
>
> for each c found do the same and then remove it from the dir list that
> is recursed into by os.walk. Also remove any .svn directories from
> os.walk without any processing.
>
> Now there should be a clean copy of the project ignoring everything that
> needs to be ignored.
>
> I can't help but think there ought to be an easier way, but hey, job
> security and all that.
>
>
>

A slightly better (simpler) algorithm:

Against that working copy run a python script based on os.walk that 
looks for
a. subdirectories
b. files
which are not present on the pristine working copy.

For every such file or directory found
     invoke a subprocess that calls svn propget svn:ignore on its parent 
directory analog in the pristine working copy.
	If its file name is not already in the list of values returned
	AND
	If its file name does not wildcard-match anything in the list of values 
returned
	THEN
	append its name to the list
	invoke a subprocess that calls svn propset svn:ignore passing in the 
appended-to list.
For every directory found it may be removed from the dirs list returned 
by os.walk, thus pruning the tree since everything in it will be blocked 
by its parent directory.

Also prune the .svn directories as part of the os.walk

There is no need to look for executable files.  Any file present in the 
built working copy and not in the pristine working copy should be ignored.

When the script has completed, svn commit may be run against the second 
working copy.


	


Re: svn:ignore with recursive and non-recursive patterns

Posted by Steve Cohen <sc...@javactivity.org>.
On 12/01/2010 12:29 PM, Steve Cohen wrote:
> I have a need to define a number of svn:ignore patterns in my project.
>
> Some are specific directories somewhere in my project tree. Others are
> particular file types created by a build process such as *.o which may
> be found in any number of directories.
>
> However, the svn propset command only allows the recursive -R switch to
> be applied to the entire set of values for the svn:ignore property.
> Whereas what is needed is to be able to apply the recursive switch to
> the VALUE(e.g. *.o), not the KEY (e.g. svn:ignore). Is there any way of
> achieving this? There doesn't appear to be one. Yet without it,
> svn:ignore is useless, or at least too cumbersome to be used well.
>
> Steve Cohen
>
>
The following methodology seems to work pretty well in my case:

Check out the pristine source TWICE into two local working copies.

One one working copy perform the complete build.

Against that working copy run a python script based on os.walk that 
looks for
a. executable files
b. other generated files of interest
c. newly created directories.

for each a or b found, use the python subprocess module to invoke svn 
propget on the mirror of that directory in the second working copy. 
This is necessary because, svn update and svn commit do not work on a 
directory tree containing unversioned directories.  Check to make sure 
that the object is not already in the properties, and if not, add it to 
the list and save it with svn propset.

for each c found do the same and then remove it from the dir list that 
is recursed into by os.walk.  Also remove any .svn directories from 
os.walk without any processing.

Now there should be a clean copy of the project ignoring everything that 
needs to be ignored.

I can't help but think there ought to be an easier way, but hey, job 
security and all that.

Re: svn:ignore with recursive and non-recursive patterns

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Steve Cohen wrote on Thu, Dec 02, 2010 at 07:48:05 -0600:
> On 12/02/2010 12:23 AM, Daniel Shahaf wrote:
>> You can use 'propedit --editor-cmd=script.sh **/', where script.sh
>> appends '*.o' to argv[1].
>>
> Does svn propset svn:ignore accept the **/filename idiom as a legitimate  
> pattern indicating recursion or are you saying that the script would  
> need to manually execute the recursion indicated by the idiom?

Expanding **/ to filenames is done by the shell.  I used zsh syntax;
with other shells, you can use find(1).  In any case, the script doesn't
do any recursion, it just edits the file whose name is given by argv[1].

Re: svn:ignore with recursive and non-recursive patterns

Posted by Steve Cohen <sc...@javactivity.org>.
On 12/02/2010 12:23 AM, Daniel Shahaf wrote:
> You can use 'propedit --editor-cmd=script.sh **/', where script.sh
> appends '*.o' to argv[1].
>
> Another example, the following is a "Fix typo in the log message" idiom:
> % svn propedit --revprop -r69426 --editor-cmd 'sed -i s/foo/bar/' svn:log
>
> Steve Cohen wrote on Wed, Dec 01, 2010 at 12:29:58 -0600:
>> I have a need to define a number of svn:ignore patterns in my project.
>>
>> Some are specific directories somewhere in my project tree.  Others are
>> particular file types created by a build process such as *.o which may
>> be found in any number of  directories.
>>
>> However, the svn propset command only allows the recursive -R switch to
>> be applied to the entire set of values for the svn:ignore property.
>> Whereas what is needed is to be able to apply the recursive switch to
>> the VALUE(e.g. *.o), not the KEY (e.g. svn:ignore).  Is there any way of
>> achieving this?  There doesn't appear to be one.  Yet without it,
>> svn:ignore is useless, or at least too cumbersome to be used well.
>>
>> Steve Cohen
>
>
Does svn propset svn:ignore accept the **/filename idiom as a legitimate 
pattern indicating recursion or are you saying that the script would 
need to manually execute the recursion indicated by the idiom?

Re: svn:ignore with recursive and non-recursive patterns

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
You can use 'propedit --editor-cmd=script.sh **/', where script.sh
appends '*.o' to argv[1].

Another example, the following is a "Fix typo in the log message" idiom:
% svn propedit --revprop -r69426 --editor-cmd 'sed -i s/foo/bar/' svn:log

Steve Cohen wrote on Wed, Dec 01, 2010 at 12:29:58 -0600:
> I have a need to define a number of svn:ignore patterns in my project.
>
> Some are specific directories somewhere in my project tree.  Others are  
> particular file types created by a build process such as *.o which may  
> be found in any number of  directories.
>
> However, the svn propset command only allows the recursive -R switch to  
> be applied to the entire set of values for the svn:ignore property.  
> Whereas what is needed is to be able to apply the recursive switch to  
> the VALUE(e.g. *.o), not the KEY (e.g. svn:ignore).  Is there any way of  
> achieving this?  There doesn't appear to be one.  Yet without it,  
> svn:ignore is useless, or at least too cumbersome to be used well.
>
> Steve Cohen