Recovering from an unfortunate “svn copy”

recoverysvn

This afternoon, upon noticing a broken build and the fact that some files looked like very old versions (about 2 weeks old), I checked the svn log. Apparently just this afternoon, 1 of the developers did an "svn copy" of a directory from an older revision to the same directory. Thus it appears that the latest version "i.e. head" of all the files in that directory are really old, and all the history "i.e. log" is even older.

However, I think I can recover by using another "svn copy" (i.e. the disease is the cure). What I am considering doing is finding the revision where the bad "svn copy" was done (say rev 1234) , subtracting 1 (1233) and doing:

svn copy -r 1233 file://path/to/messed/up/dir file://path/to/messed/up/dir

That should restore the latest version, as well as get back all my history. Am I right about this?

Best Answer

According to the SVN book,

svn merge -c -1234

should do the trick.

There's a whole section about this in the book.

The verbose explanation: -c -1234 translates into -r 1234:1233, which reverts the change from revision 1234.