In my project I have a folder with resources which I don't want to manually add or remove to the repository as I add or remove them to my working copy.
I wrote a simple bash script that checks svn state and calls svn add for files marked with a ? and svn remove for files with a !. I added this bash script to my build script. The problem is, svn remove returns an error when called with a file that doesn't exist locally anymore. This results in my build script being aborted and returning an error too.
Is there a way to suppress these errors? I tried --force and --quiet. Didn't help.
Example:
MacBook-Pro:proj Bill$ echo "test" > foo.bar
MacBook-Pro:proj Bill$ svn st
? foo.bar
MacBook-Pro:proj Bill$ svn add foo.bar
A foo.bar
MacBook-Pro:proj Bill$ rm foo.bar
MacBook-Pro:proj Bill$ svn st
! foo.bar
MacBook-Pro:proj Bill$ svn rm foo.bar
D foo.bar
svn: 'foo.bar' does not exist
There are (at least) two different cases in which svn stat prints a line with an exclamation point:
svn rm was not used.svn add was used on the file, and the file does no longer exist in the working directory.svn rm works in the first case, but exits with an error in the second case. There are several ways to solve this issue - depending on what you want to achieve:
touch "$filename" ; svn rm --force "$filename".svn revert "$filename".So, to answer my question, using --keep-local fixed the problem.
Here is the script I ended up using. This will check for files marked as not versioned (?) and call svn add for them. Then it checks for files marked as missing (!) and call svn rm for them.
svn st "$Resources" | grep '^?' | sed 's_^? \(.*\)$_svn add "\1"_g' | sh
svn st "$Resources" | grep '^!' | sed 's_^! \(.*\)$_svn rm --keep-local "\1"_g' | sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With