views:

1630

answers:

7

I've been using various source control systems for a while, but when it comes to reverting changes I'm not yet an expert. Can someone help given this scenario:

Scenario

  • Given a bug was introduced in revision #5
  • And 3 files were changed in revision #5
  • And changes in 2 files were responsible for the bug
  • When the customer discovers the bug in a release of revision #9 (HEAD)
  • Then 2 of the files causing the bug from revision #5 must be reverted to revision #4
  • And changes from revision #6 to HEAD must be applied to the two files

I expect there must be a way to compare revisions #4 and #5 of the two files and generate a patch that undoes the changes in revision #5, which can then be applied to the HEAD revision to roll-back the defect.

A: 

If you are using http://tortoisesvn.tigris.org/ then this is a rather simple process. Just right click on a file and select "log" to get a list of changes between now and a selected reversion. Then it is a matter of reverting the two files to revision #4 and committing the changes :)

nlaq
+2  A: 

Here is a link to svn book explaining all about reverts and history.

To do a diff you would do something like svn diff -r 4:5 somefile.txt

J.J.
Excellent that's exactly what I was looking for. Thank you.
Robert Walker
+1  A: 

check out current version, then svn merge -r 5:4 file1 file2 (that's from memory, and might not be totally correct)

Mark Bessey
+3  A: 

Usually a reverse merge will be sufficient to roll back a committed changes...

CMS
A: 

I assume you are using TortoiseSVN in my answer.

I don't think your scenario will lead to a roll-back of the files, because you still want to preserve the history of each file. Most of the time, what you are going to do is just find and fix the bug and commit a new change to this file.

If you want to compare two revision, it's pretty easy in tortoiseSvn, right click on the file, then go in TortoiseSvn->Show Log. Then select both the revision you want to compare, right click and then Compare Revisions.

If you want to find who is responsible for the bug, you can use the menu item Blame in TortoiseSVN... This will let you know who modified each line and at which revision.

Oh and if you want to revert a file back to a previous version, you can do so in TortoiseSvn->Show Log an then you select the revision you want to revert to, right click and select Revert to this revision.

EtienneT
A: 

I think you need to reverse merge first between 5:4, then revert the correct file

  1. svn merge -r 5:5 http://svn.example.com/repos/calc/trunk

  2. svn revert correctfile

you probably end up with at weird state on the 2buggy files That you can hopefully can solve manually.

Jonke
A: 

To read up on the details see: svn manual - Undoing Changes

As described by mark you'll want to do:
svn merge -r 5:4 file1 file2
This means merge in the change from 4 to 5 backwards ie. undo the changes

You could also type:
svn merge -c -5 file1 file2
This means apply the change that took place in commiting revision 5 backwards.

Next you should manually review the changes.

Finally you must commit the changes (above merges only changed your working copy).

morechilli