views:

123

answers:

3

I'm relatively new to Subversion, coming from Source Safe, and it's driving me nuts. Using the Tortoise interface, Commit kept showing me .java files in my bin directory which it said were "missing" - ok, that's a separate question. Basically, when I tried several things to get rid of the spurious "bin" message, Tortoise instead deleted my entire source directory. I tried re-adding things, but when I added, it came in as new, with no history.

How do I take Subversion back to a particular revision? As if I had never happened? I know how to do this in VSS, but every time I try in TortoiseSVN, it just modifies my working copy. I don't want to then check in my working copy, because that would lose me all my history. Can Subversion forget?

Tried looking in stackoverflow already, btw, but the closest thing I found was exporting and reimporting the entire repository, and I don't think I'm at that point yet. Subversion must be able to do this most simple thing!

+2  A: 

You don't take the SVN back; you take your working copy back, and then commit it.

EDIT: depending on what the command is (IE, svn cp instead of cp), subversion will remember the ancestry (history) of the file.

You could either reverse-merge it, or you could copy it. Copying is probably the better choice for this.

If I was going to do it, I would do:

svn update
svn rm directory
svn ci -m "temporarily removed the content"
svn cp -r [revision] directory ./directory
svn ci -m "copied revision [revision] to current"

However, the possibly better way to do it, would be:

svn update
svn merge -r HEAD:[revision] directory directory
svn ci -m "reverted back to [revision]"

For some of the places where I put 'directory', you may have to use the URL of the location in the repository, for example, if you just removed the root directory (and thus there's nothing left to reference off of). Either that or with the merge, the first one is the URL to the repo, and the second one is the local directory... though it will probably work with just using the local dir twice.

Just remember; if it didn't work properly, don't check it in :D (this is an advantage with using the second method... also, it requires less data transfer)

zebediah49
+4  A: 

Subversion won't forget, but you can do something like the following:

Let's say your current revision is 100, and you want to go back to revision 70. You'll be creating a revision 101, which is exactly the same as 70.

1) Check out a nice clean working copy.

2) Merge (backwards) changes.

svn merge -r100:70 http://repo.com/my/project/trunk

3) Check sanity. Is your working copy exactly what you wanted? If so:

svn commit -m "rolled back to the good old days of r70"

timdev
+1  A: 

Since you specifically asked about TortoiseSVN you can do the following:

  • right click in your working directory
  • TortoiseSVN
  • Update to Revision
  • Click on Log
  • Choose the revision you want (this puts the revision number into the Revision box - if you already know the revision number, you can just type it in straight away).
  • Click ok

Then just commit your changes to the repository with an appropriate message.

Blair McMillan
Thanks, I don't have access to the repository box right now.
orbfish