views:

379

answers:

2

A while back I asked link text and I got some great answers. What I would like to know is if there is a way to keep the files under my web applications document root, and when I make a change, commit them back to the repository.

From what I understand, in order to work on files, they can't be in the web root. Having to move them out to somewhere else just to work on them seems counter-intuitive to me. Am I missing something?

Thanks!

+5  A: 

Just check out the svn repo to a directory and make that directory the web root. You will want to have an apache policy that will not serve the .svn directory but other than that there is no issue.

This is what I have in my httpd.conf to protect svn directories:

#Protect svn directories
<DirectoryMatch "^/.*/(\.svn|CVS)/">
Order deny,allow
Deny from all
</DirectoryMatch>

Eddy
So say I have a web site at C:\www\samples\htdocs\. I would have the actual repository somewhere else and check out into C:\www\samples\htdocs\? What about the fact it says it should be an empty directory?
patricksweeney
I can't see windows being that much different. In general, I'd go to /var/www/ and checkout a copy that would make a directory something like /var/www/my_repo In apache I'd set my doc root to /var/www/my_repo
Eddy
You can use the "svn:ignore" property to allow other items in document root without them being checked into svn. Easiest way is to checkout from SVN into EMPTY document root, then copy in other items and mark each with svn:ignore, then check in document root to record the svn:ignore properties.
Chris Nava
For what it's worth, in Linux at least you can check out into a nonempty directory as long as the existing files don't have the same names as the ones you're checking out.
David Zaslavsky
Thanks for the tips! I accepted the other answer as to the fact it seems exactly what I was envisioning but these all give me some insight as well.
patricksweeney
+2  A: 

in order to work on files, they can't be in the web root

There's no truth to that. Maybe you're thinking of the fact that files which can be modified/edited by the web server shouldn't be under the document root. But as long as you're not using the server itself to do the editing (which would be the case if, say, you created some kind of text editor web application), it's perfectly fine and a completely normal practice to edit files in the document root.

You might be interested in something like my setup: I have the repository which holds my website on the same physical machine as my web server. One working copy is checked out into the web root on that machine, and I have another working copy checked out on my laptop, where I do my development and testing. Now the fun part: I added a hook to the SVN repository so that every time anything is committed to the repository, it automatically updates the working copy in the web root. This way the web root always has the latest revision of the website code, but I can still work on the site without having access to the server.

EDIT: here's the script

David Zaslavsky
I would definitely be interested in that....that is exactly what I am invisioning. Thanks!
patricksweeney