svnhookpost-commit

Using SVN post-commit hook to update only files that have been committed


I am using an SVN repository for my web development work. I have a development site set up which holds a checkout of the repository.

I have set up an SVN post-commit hook so that whenever a commit is made to the repository the development site is updated:

cd /home/www/dev_ssl
/usr/bin/svn up

This works fine but due to the size of the repository the updates take a long time (approx. 3 minutes) which is rather frustrating when making regular commits. What I'd like is to change the post-commit hook to only update those files/directories that have been committed but I don't know how to go about doing this. Updating the "lowest common directory" would probably be the best solution, e.g.

If committing the follow files:

It would update the directory: /branches/feature_x/

Can anyone help me create a solution that achieves this?

Update:


Solution

  • You might use svnlook dirs-changed and svn up -N to update only the contents of each folder changed:

    cd /home/www/dev_ssl
    svnlook dirs-changed [REPOS] -r [REV] | xargs /usr/bin/svn up -N
    

    Or, if per-file might be better for you (using sed to strip action characters):

    svnlook changed [REPOS] -r [REV] | sed "s/^....//" | xargs /usr/bin/svn up