How to revert a file to older revision in SVN

2

At my work, we use svn. I use tortoisesvn on my windows PC as a windows shell/explorer extension. I was maintaining a *.c source file in svn. One of my colleague made some changes on top of my version and checked it in, but not without testing fully all his changes! As a result of that the code now is broken for certain test cases. He said he did not merge it properly while checking in the changes in svn, hence this breakage. Whatever! There are other teams which update this file, so this would break their work.

  1. What is the command to revert this particular file to older working revision? (He has his changes locally, so I would not bother about that)

  2. If there is no direct command to do this, what is now my way out of this mess.

  3. When I read , I heard of something 'reverse merge'. What exactly is that, and does it help me, if yes how?

goldenmean

Posted 2011-05-27T15:18:38.290

Reputation: 2 087

You should be able to manually select which version of the file you want to view. I would simply find the last working copy and save the change then perform a commit. You sure the application is tortoisesvnit and not tortoisesvn? – Ramhound – 2011-05-27T15:54:52.007

@Edited to correct typo in OP. Isn't there a command to just revert to a working revision # I give to it. – goldenmean – 2011-05-27T16:02:08.627

Answers

1

Here's a reverse merge. It will get you what you want.

  1. Merge the revision that's wrong with the revision you want into your working copy path.
  2. Test your code
  3. Commit the files back to the repository

You will now have a revision that is fixed, but leaves the broken one in the repo.

The merge command takes three parameters: first source, second source, working copy path. Since you are rolling back, the two sources will have the same path but different revision numbers. The higher revision number goes first.

Command-line Example:

merge svn://example.com/repo/folder/changedFile.txt@HEAD svn://example.com/repo/folder/changedFile.txt@215 ./folder/changedFile.txt

Use the "Show Log" button in TortoiseSVN to find the revision easily.

Chris Ting

Posted 2011-05-27T15:18:38.290

Reputation: 1 529

Do u know exact svn commandline for doing this. It seems to be the correct way. Other way is download/checkout the last known working version explicity by selecting its revision #. Then commit it back. But i would try merging first. – goldenmean – 2011-05-27T17:43:59.747

Edited answer to include command line example. – Chris Ting – 2011-05-27T19:45:15.403

2

You can also reverse merge single file by right-clicking the filename in the Log Messages window.

Vinix Wu

Posted 2011-05-27T15:18:38.290

Reputation: 21

0

Guided by the commit messages, you should be able to download a previous revision of the file, a revision which does not contain the changes which broke the file.

Certainly the last check-in you did, contains the correct and working version of the file, when u merge, you usually use two sources to produce a new one, either a working copy or two seperate branches, so, what your friend did was just create a new revision.

Download the file from YOUR last check-in, that should contain the last working code before the changes. TortoiseSVN allows you to do that by 'checking out' specifying a revision number, perhaps you'll need to explore the Repository (using TortoiseSVN Repository Explorer) and identify the desired revision number.

This is the way i do it, has worked before for me :)

Hope this helps.

jgemedina

Posted 2011-05-27T15:18:38.290

Reputation: 171

0

TortoiseSVN can do the reverse-merge for you. Go the the log pages for the SVN project, right-click on the revision you'd like to change to and choose 'revert'.

Jossie90

Posted 2011-05-27T15:18:38.290

Reputation: 1