Extract Files From Subversion for Propagation

Problem:

You store your site files in a subversion repository for source control. When you update your site you don't want to upload the entire tree (nor the svn working copy files) nor do you want to spend time hunting and pecking for the changed files.

Solution:

Use the following script on *nix to extract non-svn files that have recently changed:

find . -not ( -name '.svn' -type d -prune ) -not ( -name '*.log' ) -type f -mmin -240 -print | zip ~/Desktop/prop -@

Discussion:

We're building upon syntax we've used in two previous posts: delete files from a subversion sandbox and zip changed files in your subversion sandbox.

In this case we are using the "find" command combined with the -mmin option to find file modified within a specified number of minutes. find . -mmin -X will find files in the current directory structure modified in the last X minutes. find . -mmin X will find files in the current directory structure modified before X minutes ago.

In the example above we're findiing all files not in .svn folders modified less than 240 minutes ago. We pipe the results of that find to the zip utility to zip up the results. We are also filtering out the Rails-specific "development.log" from being zipped.

If you want to propagate an entire directory structure you can use svn export on your working copy to extract out all your files (this is the same as a checkout without the .svn folders). You can also svn export from the repository to pull a specific revision or branch.

svn export . ~/Desktop/prop
svn export http://repos/project/tags/release_1.0 ~/Desktop/prop

And for those Rails developers you can obviously use Capistrano to get around most of these issues.


Comment: