How do you revert ONLY directories in an SVN working copy?

17.1k Views Asked by At

I want to revert a directory and all sub-directories in an SVN working copy so they match the repository but I don't want to touch any files inside those directories.

One of my SVN applications recursively set an SVN property on every directory in my working copy but I want to revert those changes to stop it highlighting them and trying to commit the changes to the SVN properties. Simply changing it to match the HEAD doesn't work.

Any ideas? I've read through various SVN resources but none of them seem to deal with this edge case.

4

There are 4 best solutions below

0
On BEST ANSWER

You could use find combined with svn revert:

find . -type d | grep -v .svn | xargs svn revert

This won't touch any files inside the directories unless you use the -Roption (which is equivalent of --depth=infinity).

0
On

Firstly, make a copy of your working copy somewhere safe. :)

You can edit properties on svn working copies using commands like this:

REM Delete all mergeinfo properties recursively
svn propdel svn:mergeinfo -R
0
On

On Windows from the command line you could do this:

for /d /r %i in (*) do svn revert %i

If you call that from a batch file use %%i instead. Please back up first!

This command is dirty and will go through all directories, even unmodified ones or the ones not under svn. You could use something like this Ruby script to do in a cleaner way:

`svn st`.split("\n").grep(/^ M\s+(.*)/) { $1 }.find_all { |i| File.directory? i }.each do |i|
  system "svn revert #{i}"
end
8
On

Works on all platforms:

svn revert . --recursive

(Note that this will revert everything, not just directories.)