I needed to roll back an SVN commit done recently to an init script for one of our daemons, it’s a very easy process!
First we need to see what the latest revision number of the file that we want to roll back is
<br />
Chill:files idimmu$ svn info slee<br />
Path: slee<br />
Name: slee<br />
URL: http://svn.idimmu.net/msu/trunk/puppet/modules/jnetxslee/files/slee<br />
Repository Root: http://svn.idimmu.net/msu<br />
Repository UUID: 573313b0-15b8-499c-acf0-a5a26a3c7166<br />
Revision: 1517<br />
Node Kind: file<br />
Schedule: normal<br />
Last Changed Author: idimmu<br />
Last Changed Rev: 1256<br />
Last Changed Date: 2010-08-12 10:51:15 +0100 (Thu, 12 Aug 2010)<br />
Text Last Updated: 2010-08-12 10:50:57 +0100 (Thu, 12 Aug 2010)<br />
Checksum: 8940fdf3ed6ee8281b94f55c2fe7880a<br />
As you can see the Last Changed Rev is 1256, this is the important number
Now we want to run a diff of the revision prior to the commit, 1255, and the current file, 1256
<br />
Chill:files idimmu$ svn diff -r 1255:1256 slee<br />
Index: slee<br />
===================================================================<br />
--- slee (revision 1255)<br />
+++ slee (revision 1256)<br />
@@ -40,12 +40,12 @@</p>
<p> case "$1" in<br />
start)<br />
- if kill -0 `cat $SLEEPID` > /dev/null 2>&1; then<br />
+ if kill -0 `cat $SLEEPID` 2> /dev/null ; then<br />
echo "SLEE is already running"<br />
exit<br />
else<br />
rm -rf $SLEE_HOME/slee/tmp/*<br />
- if $SSD --start -b -c $RUNAS -d $SLEE_BIN -x $SLEE;then<br />
+ if $SSD --start --oknodo -b -c $RUNAS -d $SLEE_BIN -x $SLEE;then<br />
echo "Starting SLEE"<br />
else<br />
echo "Cannot start SLEE"<br />
@@ -53,8 +53,9 @@<br />
fi<br />
;;<br />
stop)<br />
- if $SSD --stop --quiet --retry=TERM/30/KILL/5 --pidfile $SLEEPID;then<br />
- echo "Stopping SLEE"<br />
+ echo "Stopping SLEE"<br />
+ if $SLEE_HOME/slee/bin/node.sh -h $SLEE_HOME -m com.jnetx.slee.management.hostagent.Shutdown 1 >/dev/null;then<br />
+ echo "Stopped SLEE"<br />
else<br />
echo "Problem stopping SLEE"<br />
fi<br />
The diff shows the changes so you can confirm that you’re on the right track!
We then just issue a merge to revert the file, and then a commit!
<br />
Chill:files idimmu$ svn merge -r 1256:1255 slee<br />
--- Reverse-merging r1256 into 'slee':<br />
U slee<br />
Chill:files idimmu$ svn commit -m "rolling back the slee init script"<br />
Sending files/slee<br />
Transmitting file data .<br />
Committed revision 1519.<br />
and we’re all done