user244333
user244333

Reputation:

How do we check if a file is committed to the SVN repository?

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.

edit

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.

Upvotes: 2

Views: 3096

Answers (2)

adamnfish
adamnfish

Reputation: 11255

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.

Upvotes: 2

XstreamINsanity
XstreamINsanity

Reputation: 4296

If it's anything like the SVN we use at my work, you can't. The only thing there is is "Latest Version" which was the last time it was committed. Are you asking about knowing when a file is added to the repository?

Upvotes: 0

Related Questions