My thoughts as an enterprise Java developer.

Tuesday, October 02, 2007

Converting .cvsignore file to Subversion svn:ignore property

If you have converted a cvs repository to a Subversion repository and need to convert .cvsignore files to subversion svn:ignore properties then the following script should be useful to you. Note that it probably doesn't handle spaces in filenames.

#!/bin/bash

find . -name ".cvsignore" -print | sed "s/\/.cvsignore//" | tee ignoredirs.txt

for i in `cat ignoredirs.txt`
do
echo Processing $i/.cvsignore
svn propset svn:ignore -F "$i/.cvsignore" "$i"
svn remove "$i/.cvsignore"

done

2 comments:

Anonymous said...

I suspected that there was such a trick, and thanks for showing it.

You can also use

-exec dirname '{}' ';'

on the find command to trim it down to just the directory names.

The only suggestion, as far as the spaces problem is concerned, is to translated the blanks into 'illegal characters' and then strip them again when they come out of the for loop.

tr ' ' '#' | tee ignoreddirs.txt

for i ...
do
dir=`echo $i | tr '#' ' '`
...
done

Denis Howe said...

Use

... | while read i

instead of a temporary file.