General, Subversion, Technology, Version Control Systems

Subversion Revert with Externals


Disclaimer: I know Git rocks, but people still use Subversion 🙂 !

Let’s say you have a Subversion checkout containing externals. Now you’ve made changes in many places within the folder structure and you want to get back to the original clean state.

So your typical approach would be to go to the top directory of the working copy and do a recursive revert using:

svn revert -R .

But unfortunately nothing happens! The reason is that the working copy is made up of sub folders containing externals and in order to revert them you need to go into each sub directory and then issue the svn revert command. This can be cumbersome if you have a working copy containing many subfolders corresponding to externals.

Well the solution is pretty simple if you have a bash shell (Windows users will require Cygwin or something similar)

for d in ./*/ ; do (cd "$d" && svn revert -R .); done

This little bash script will change (cd) into all sub folders using a loop and execute an svn revert within each ‘external’ folder recursively.

The solution was inspired by this thread on StackExchange.

Advertisements
Subversion, Version Control Systems

Subversion Revert All


Working with Subversion on Ubuntu requires that you get to know actual svn commands as opposed to using GUI tools such as TortoiseSVN in Windows.

Normally svn help gives you a list of available commands. But recently I needed to revert all my local changes in my code and couldn’t figure out the command (or more correctly the switch) required to do this operation.

Then I came across this blog which has a combination of awk and svn revert which looks pretty cool. But the simpler more efficient solution as given by the comments in the post is

svn revert -R .

Note the period after “-R”

This worked for me!