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?
SVN Checkout We want to check the contents of our repository out into this folder. So we right-click on this folder and select 'SVN Checkout…' From here we'll specify the location of the repository that we want to check our files out from.
By checking out files from a Subversion repository, you obtain a local working copy of the repository, which you can edit. After making the necessary changes, you can publish the results by committing, or checking in your changes to the repository.
When you check out with the --force option, any unversioned file in the checkout target tree which ordinarily would obstruct the checkout will still become versioned, but Subversion will preserve its contents as-is.
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.
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.
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