views:

708

answers:

3

Sometimes I want to get a file from a repository for use in some project that's not under source control. Let's say it's just a file full of handy utility functions. I know I can just to an svn export but I'd like to be able to do an svn update from time to time to get the latest version of the file.

The important thing is I don't want to be able to commit any changes to the file from the new project; I just want to be able to do updates to refresh the file.

Is there any way to checkout a file as read-only?

A: 

This looks like emulating the CVS read-only checkout, and I do not think it has been implemented in Subversion.

The ideal scenario would be to remove commit access on the server side, but I suppose your user need to modify a file in a certain workspace, while not modifying (and comiting) the same file in another environment (i.e. in that project which is not under source control).

Another possibility would be to merge that file into a SVN branch declared as read-only (through a per-directory access setting).
That way, you can update the file in this branch , but your users who checkout that file won't be able to commit that file, while retaining the possibility to commit on the repository.

VonC
A: 

You probably have some form of build automation (make, ant, etc.) for compiling. Why not add an 'update' step to your make file, that looks something like this:

update:
        svn update
        svn export <<export parameters go here>>

Then whenever someone would type svn update they can type make update and have the same effect.

Craig Trader
+1  A: 

One way to do it is, when you check out the file, add a property to it (locally!) like readonly or some such. You can even script up a read-only-checkout sequence that does it for you in one step. This, in itself, does not make the file read-only.

What you can do is, write a pre-commit hook which does an svnlook propget into the potential transaction, and if readonly is defined, disallow the commit.

When you do a regular svn update it should work fine with no extra work.

This may be overkill, but if it's a feature you'd like to use often, it may be helpful.

JXG