I am developing a java based eclipse plugin that monitors file activity. I need to find out if a given file is checked into the SVN by the user.
There are two files. Local file and repository. I have to keep track of the local file and make sure the user commits it to the repository every time he saves it locally.
You could make svn do the work for you by running svn status /path/to/my/file from the shell on the path to the file. If it isn't checked in then you will get ? /path/to/my/file back (it begins with a question mark). If it is checked in and unmodified you will get no response from svn status, otherwise the line will begin with the character describing the file's status (eg. A, M, D).
Bear in mind if the file is not within an svn repository svn status will throw a warning svn: warning: '/path/to/my/file' is not a working copy.
[edit] Having seen your clarification, you need to check for all the status flags (added, modified, deleted etc.) and remind your user to commit where appropriate. svn help status contains the (exhaustive) full list.
If you run svn status from within the project without providing a path it gives you the status of all the files in the repository. If it is unmodified this will yield nothing, otherwise any changes will be printed to stdout. You probably want to do this, rather than running through each file to check its status.
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