Archives
Tags
- General (13)
- Food (1)
- Cooking (1)
- Ruby (6)
- Rails (2)
- Svn (2)
- Linux (8)
- Git (1)
- Firefox (7)
- Porn (1)
- Freyja (1)
- Witchhammer (4)
- Music (1)
- Merb (3)
- Poetry (0)
- Bolverk (3)
- Sinatra (1)
- Discogs (1)
- Centos (1)
- Python (1)
- Whinging (1)
- Travel (2)
- Scheme (4)
- Lisp (4)
- Sicp (1)
- Rot13 (1)
- Czech (1)
- Metal (1)
- Passenger (1)
An improved shell script for Svn resetting
A few weeks ago I posted a simple script for resetting an Svn repository to an earlier revision (and recording it as a new revision, so the reset is resettable!).
I decided it was totally shit, and so, I have simplified it a little bit:
- You no longer have to pass in the URL for the central repository. The script will figure it out for you.
- The working copy (second) argument is optional. It defaults to the current directory.
Anyway, here it is:
if [ $# = 0 ]
then
echo "Resets an Svn working copy to an earlier revision."
echo "svnreset <revision> [PATH...]"
else
dir=$2
: ${dir:="."}
# Find repository URL using AWK.
repo_url=`svn info $dir | awk '/^URL: (.+)$/ { print $2 }'`
# Update working copy, merge into older revision, commit with message.
svn update $dir
svn merge -rHEAD:$1 $repo_url
svn commit -m "Reverted back to r$1"
fi
exit 0Call it like this (with an appropriate revision number): $ svnreset 1242