views:

467

answers:

4

I have several projects in my repository, each project has it's own folder. Is it possible to remove the last revision of one of the projects without changing anything else?

Example: Project A's latest version was committed creating rev. 50. Work on other projects goes on, the repository is now at rev. 60.

Now the user of A comes back and requests to remove the changes of the last version because they don't work out for him. He wants to go back to the previous version and all further changes should be done starting from there.

At this point I would like rev. 50 to disappear so that project A can go on as if rev. 50 never happened.

The only way I can see is to create a branch and from now on work on that branch. But that just creates many branches over time and the project's history gets cluttered.

What is a good solution for this scenario?

+6  A: 

Short answer, you don't. It's really hard to actually erase a commit from a subversion repo. Intentionally so.

Practically, the thing to do is revert that directory back to revision 49, and then commit it as rev 61.

The key thing is that you're reverting ONLY the directory in question, not the whole checkout.

Here's the relevant SVN book link: http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-4-sect-4.2

You want a command of the form "svn merge -r 60:50 xxx://path"

Paul McMillan
If you did just that, you'd lose everything you did in revisions 50-60. Not what the OP wants, I believe!
Gabriel Hurley
You can just revert the individual project you are interested in, no need to do the whole lot.
Ian
You can revert a single file, or a directory and all it's children. After reverting just perform a commit as Paul said. No need to mess around with merging stuff.
elmuerte
Again, if you revert the file, you will lose anything else you've changed in that file since that revision! Hence needing to look at what's changed and do a merge!
Gabriel Hurley
The SVN book chapter linked to actually explains it very nicely.
sbi
+2  A: 

You go back and get the file at the state it was in at revision 50 (using "update to revision"), then re-merge it with the current version if there have been any subsequent changes you want to keep. Otherwise you can just do your update to revision, then recommit the file.

There's no automatic way to do this, but with a little work by hand it's doable. That's the magic of version control.

Gabriel Hurley
+2  A: 
  1. Do an update to make sure your working copy is up to date. Make sure your working copy is clean, without pending modifications.
  2. Right click on the root folder of your project's working copy and "show log"
  3. Select (with ctrl/shift to select multiple) the revisions you want to undo
  4. Right click the selected revisions and "revert changes from these revisions"
  5. Check the modifications that the undo operation has made on your working copy. Resolve any conflicts if necessary.
  6. Commit the modifications

The answer by Gabriel Hurley that you have currently had accepted doesn't make sense: it is not possible to commit after doing an "update to revision". That operation rolls back the BASE revision that your working copy is based on. When trying to commit changes, subversion will then complain that the files and folders are out of date.

You want the revert to revision or revert changes from revision features, not "update to revision".

Wim Coenen
A: 

if you do want changes 51:60

svn merge -r 50:49 A/trunk/
#the most painful experience in your life
svn commit -m "reverting to rev49"

Note that this often just does not work.

if you do want changes 51:60, manual way

svn diff -r 50:49 A/trunk/
#review changes from the diff and apply them. or patch.
svn commit -m "reverting to rev49"
gcb