Hello
I having one repositry serving a couple of web-projects.
I use the following python script to update web-server working copyes.
Hope this will help.
-------------------------------------------------------------
#!/usr/bin/python
import sys
import os
result = 1
# get repo->local copy dictionary
filename = '/var/svn/hooks/web-conf.py'
if filename and os.path.isfile(filename):
execfile(filename)
else:
sys.exit('Unable to execute ' + filename)
# get repository and revision from args
try:
repository = sys.argv[1]
revision = sys.argv[2]
except IndexError:
sys.exit('Not enought parameters given')
# find working copy for passed repository
try:
local_copy = local_copyes[repository]
except KeyError:
sys.exit('Couldn\'t get working copy for given repository...')
# get list of changed directories
fd=os.popen('svnlook -r ' + revision + ' dirs-changed ' + repository)
changed_dir_list = fd.readlines()
fd.close()
# get the top dir changed
try:
top_changed_dir = os.path.commonprefix(changed_dir_list).strip()
except IndexError:
sys.exit('No dir\'s changed by this commit')
update_path = local_copy + top_changed_dir
if os.path.isdir(update_path):
result = os.system('svn update ' + update_path)
else:
sys.exit('Sorry, \'' + update_path + '\' is not a directory...')
sys.exit(result)
------------------------------------------------------------
Contents of the /var/svn/hooks/web-conf.py :
local_copyes = {
'/var/svn/test': '/tmp/wwwsvn/test/',
'/var/svn/web': '/var/www/'
}
On Thu, 29 Jun 2006 04:58:41 +0400, Graham Anderson <grahama@siren.cc>
wrote:
> Hi
>
> 1) Is there an example script and tutorial on how to update a live web
> site with a post-commit hook script ?
> 2) Does this comply with a 'best practices' use for subversion ? At
> this point, I am a bit too green to evaluate if this is ok.
>
> I am very new to subversion so any help is appreciated.
>
> From: http://subversion.tigris.org/faq.html
>> I'm managing a website in my repository. How can I make the live site
>> automatically update after every commit?
>>
>> This is done all the time, and is easily accomplished by adding a
>> post-commit hook script to your repository. Read about hook scripts in
>> Chapter 5 of the book. The basic idea is to make the "live site" just
>> an ordinary working copy, and then have your post-commit hook script
>> run 'svn update' on it.
>
>
>
>
>
> many thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
--
Sergey Volkov
Internet Applications Team Leader
RealEast Networks LLC
http://www.realeastnetworks.com
mailto: sergeyv@realeastnetworks.com
gmail: Serg.Volkov@gmail.com
ICQ: 117726485
JID: sergeyv@nnov.stelt.ru
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Jun 30 09:55:39 2006