SVN properties are an interesting beast. One common use for them is to ignore files that svn should ignore. For example you may want the ‘target’ directory that maven generates to be ignored by svn. This way svn stat will only show changes in your source code. This post deals with adding to svn:ignore prorties.

There is a lot of litrature about setting these properties. One way to think of these properties is key-value map. The key being the ‘svn:ignore’. Lets say you have the case that you have in a directory file A that is ignored. And you want that file b should also be ignored. You may do something like this:

$ svn pget svn:ignore .

# ignore A
$ svn pset svn:ignore A .
property 'svn:ignore' set on '.'

# check that A is ignoreed
$ svn pget svn:ignore .

# now ignore B
$ svn pset svn:ignore B .
property 'svn:ignore' set on '.'

# check...
$ svn pget svn:ignore .

# what the! A is no longer ignoreed!

Did you see what just happened there? We set the for the key svn:ignore one value. And then another. And in doing so, the first value was overwritten. So if you need to add another file pattern to the svn:ignore, you need to do the following:

$ svn propget svn:ignore . > /tmp/propIgnore.txt           # current files that are ignored
$ echo "AnotherFileToIgnore" >> /tmp/propIgnore.txt        # append new files that should be ignored
$ svn propset svn:ignore -F /tmp/propIgnore.txt .          # set properties to new list of files

Using your mad bash skillz you can script to go thru and add unknown files to the ignore list



for dir in `find . -name ".classpath" | xargs dirname`
#       echo $dir
        cd $dir
        svn propget svn:ignore . > /tmp/propIgnore.txt
        svn stat | awk '{print $2}' >> /tmp/propIgnore.txt
        svn propset svn:ignore -F /tmp/propIgnore.txt .
        rm /tmp/propIgnore.txt
        cd $currentDir