Copying changed files since some revision under Subversion

I continue my previous post about getting changed files with subversion. I needed to get all changed and committed files since some revision till HEAD revision and upload them to production server. I don’t want to copy all working copy nor exporting entire repository on server. Just changed files. First solution will be filtering files by modification date. But what if you have a lot of other unversioned files in your working copy, which are changed frequently?

So the solution is to look at svn log and get affected files for each revision we are interested in. But this is boring. Use this command instead:

svn log -vq -r 104:HEAD | grep '^   [AM]' | cut -b 6- | sed 's/ (from .*:[0-9]*)$//' | sed 's|^/path/prefix/in/repository/||' | sort -u | xargs -I '{}' cp --parents {} /temporary/destination/dir

Note, there should be three spaces before [AM] in grep regex.

It will do the same. First, get log with list of changed files and without your comments for revision from 104 to HEAD (as an example). Then get only modified and added files, we don’t need deleted. After that remove first column with status indication, remove with sed “(from …:103)” svn note, if we have moved or copied resource. I used sed once more to make remote path relative to my working copy, so I can use cp command on list of files. sort -u is required to get unique list, as some files could be changed in several revisions

Tags: , ,

AddThis Social Bookmark Button

Leave a Reply