[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

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

From: Steve Cohen <scohen_at_javactivity.org>
Date: Thu, 02 Dec 2010 20:53:15 -0600

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.

        
Received on 2010-12-03 03:54:55 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.