Suppress "file does not exist" error of svn remove
bash, shell, svn
Solution
There are (at least) two different cases in which `svn stat` prints a line with an exclamation point:
- The file exists in the repository, does not exist in the working directory, and `svn rm` was not used.
- The file does not exist in the repository, `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:
- If you want to remove the file in both cases, do: `touch "$filename" ; svn rm --force "$filename"`.
- If you want to remove the file only in the second case, and revert in the first case, do: `svn revert "$filename"`.
Problem
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 ```