Skip to content

Instantly share code, notes, and snippets.

@pringlized
Created October 14, 2015 17:59
Show Gist options
  • Save pringlized/bf1d3c9071dd2081b403 to your computer and use it in GitHub Desktop.
Save pringlized/bf1d3c9071dd2081b403 to your computer and use it in GitHub Desktop.
SVN history of a file.
#!/bin/bash
# history_of_file
#
# Outputs the full history of a given file as a sequence of
# logentry/diff pairs. The first revision of the file is emitted as
# full text since there's not previous version to compare it to.
function history_of_file() {
url=$1 # current url of file
svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -n | {
# first revision as full text
echo
read r
svn log -r$r $url@HEAD
svn cat -r$r $url@HEAD
echo
# remaining revisions as differences to previous revision
while read r
do
echo
svn log -r$r $url@HEAD
svn diff -c$r $url@HEAD
echo
done
}
}
history_of_file $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment