1

I am web developer.I edit files in a local svn working copy on my own machine,our development server is a shared disk through samba,and the root directory of the server is also a working copy,what I want to do is to use a client-side svn post-commit hook to automatically update the working copy on the server whenever a developer commit some code.I've found two batch file can do this properly,one is using the subversion command,the other is using Tortoise SVN command,but the problem is both batch file update the whole working copy other than the changed files,which is very slow,often takes one or two minutes.So I think it may be faster if I can only update the changed files. Or mybe is it better to make the batch file to ssh to the server and update directly other than through samba?and how to do that?

Sorry for my poor English,any assistance would be greatly appreciated.

Community
  • 1
  • 1
treblam
  • 265
  • 4
  • 14

2 Answers2

1

You can do the following steps:
1. Use svnlook command to find out the files which were changed

svnlook changed REPOSITORY NAME  
  1. Get the output of the command into a file.
  2. Read this file dynamically and fetch it into SVN Update Command.

I can tell you how to do this in Linux, but not clear on batch files.

Nitin Srivastava
  • 480
  • 1
  • 7
  • 19
1

I had a similar problem but with Linux Server hosting SVN. May be you can take some clue from here and change it to match your Windows system.

POST_COMMIT

#!/bin/sh
wget http://localhost/update_svn.php

update_svn.php

<?php
$output = shell_exec('/media/disk3/velsvn/projects/hooks/svn_update_step1.sh');
echo "<pre>$output</pre>";
?>

svn_update_step1.sh

    ssh -i /media/d/mykey/id_rsa velsvnuser@localhost /media/disk3/velsvn/projects/hooks/svn_update_step2.sh

    svn_update_step2.sh

#!/bin/sh
cd /media/disk3/velsvn/projects/hooks
rm -f filelist
rm -f log
whoami >> log

    svnlook dirs-changed /media/disk3/velsvn/projects/  | sed "s/^..//" | awk '{ print substr( $0, 9 ) }' >> /media/disk3/velsvn/projects/hooks/filelist; sed -i -e 's#^#/media/disk2/www/htdocs#' filelist; cat /media/disk3/velsvn/projects/hooks/filelist | xargs /usr/bin/svn up -N >> /media/disk3/velsvn/projects/hooks/log

Note: 1. /media/d/mykey/id_rsa is the key which was generated for SSH access. This ensures that the system does not waits for the user to provide password to connect to SVN as well as execute shell scripts. 2. POST-COMMIT file and the shell files sh1 and sh2 were given +x mod so that they can be executed.

Please feel free to comment on this post and provide a better looking solution. All I know right now is, this solution works :)

Nitin Srivastava
  • 480
  • 1
  • 7
  • 19