Svn history bash script

January 10, 2008 at 3:17 pm Leave a comment

This is a quick and ugly script to download the complete revision history of a file using svn. All kind of obvious – but it might save someone some typing and reading of the svn documentation.

It takes a single file name in a local copy of an svn repository , and then downloads all previous revisions labelling with indexes 0, 1 et, with 0 being the most recent.

If there is an easier way to do this than writing a script I’m interested to know.

file: svn-history, requires svn to be installed.

  1. !/bin/bash
  2. Functiosn to get the complete history of files from an svn source
function bef_changed(){ file=$1; echo `changed $file` -1 | bc; } function changed(){ file=$1; svn info $file | sed -nre '/Last Changed Rev:/ {s/.*: // ; p}'; } trap "exit 1" SIGINT if [ -z "$1" ]; then echo "Usage $0 filename - Download all the previous revisions of a file, labelling them 0,1,2 etc in order of recentness."; exit 1; fi; file=$1; if [ ! -f "$file" ]; then echo "$file does not exist" fi; svn update $file; declare -i i; i=0; while true; do cp $file ${file/.*/}-$i.${file/*./}; ((i=$i+1)); rev=`bef_changed $file`; svn -r $rev update $file; if [ ! -f $file ]; then break; fi; done; svn update $file

P.S If anyone knows how to get wordpress to highlight this will pretty colours I’d like to know.

Advertisements

Entry filed under: Uncategorized. Tags: , .

Patterns – A list of forces How to uninstall packages with apt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


January 2008
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

%d bloggers like this: