SVN Revert Trunk, remove a revision as if it never existed?
Asked Answered
C

5

16

Is it possible in the svn server to remove a revision as if it never existed?

So we have the following revisions:

1004 // Commit of some bogus code that broke the build and was just wrong
1003 // Change 1.2
1002 // Change 1.1
1001
1000 *** Initial checkin

Can we we remove the 1004 in svn and revert back to 1003 as if 1004 never existed?

Forgive my ignorance, I'm still learning how to use SVN.

Crucifix answered 26/8, 2011 at 9:11 Comment(0)
B
16

VCS systems are designed specifically to make this as complicated as possible. You usually do not want to do this.

That being said, from the official documentation:

There are special cases where you might want to destroy all evidence of a file or commit. (Perhaps somebody accidentally committed a confidential document.) This isn't so easy, because Subversion is deliberately designed to never lose information. Revisions are immutable trees which build upon one another. Removing a revision from history would cause a domino effect, creating chaos in all subsequent revisions and possibly invalidating all working copies.

The project has plans, however, to someday implement an svnadmin obliterate command which would accomplish the task of permanently deleting information. (See issue 516.)

In the meantime, your only recourse is to svnadmin dump your repository, then pipe the dumpfile through svndumpfilter (excluding the bad path) into an svnadmin load command. See chapter 5 of the Subversion book for details about this.

http://subversion.apache.org/faq.html#removal

Barbarous answered 26/8, 2011 at 9:13 Comment(4)
Great, thanks for the info, that sounds like more work than it's worth for the problem I'm trying to fix. I think I'll need to do an update, checkout the revision that I need to role back to in a separate folder. Export those files over my checked out trunk code, resolve any problems and check back in.Crucifix
Not the cleanest of solutions thoughCrucifix
@Mantisimo: Martin gave this answer because you asked "to remove a revision as if it never existed". What he thought was thus: it shouldn't even appear in the log history. If that's what you want, his answer is the right one. If you just want to undo a commit, then my solution is the right one.Wiltshire
If this is the latest revision and this issue is part of creating a mirror of svn using svnsync there is hope. As per subversion.1072662.n5.nabble.com/… Remove /your_repo_location/db/revs/[rev#] Remove /your_repo_location/db/revprops/[rev#] Change rev# in /your_repo_location/db/current back to [rev#-1]Althorn
W
29

These accidents hapen, and it's not a problem if SVN keeps them in its history. What is important is to fix the accident. The way to do it is to revert the changes made by this commit. use the following commands:

svn merge -r [current_version]:[previous_version] [repository_url]
svn commit -m “Reverting previous commit and going back to revision [previous_version].”

If you're using TortoiseSVN, you could just show the logs, select the commit, and choose "Revert changes from this revision" in the context menu. It will change your working copy to the previous version, and you'll just have to commit.

I guess other graphical clients have the same option.

Wiltshire answered 26/8, 2011 at 9:29 Comment(1)
Hi JB, Thanks for your suggestion, this is what I wanted to do, however I've given Martin the correct answer as it answers my original question. I tried this but the build that I broke was a composite merge of a number of things and it didn't seem to work. I had to resort to more manual measures in the end. I think for a less complicated reversion this would of being an ideal solution (The question example was an over simplification of my problem). Thanks.Crucifix
B
16

VCS systems are designed specifically to make this as complicated as possible. You usually do not want to do this.

That being said, from the official documentation:

There are special cases where you might want to destroy all evidence of a file or commit. (Perhaps somebody accidentally committed a confidential document.) This isn't so easy, because Subversion is deliberately designed to never lose information. Revisions are immutable trees which build upon one another. Removing a revision from history would cause a domino effect, creating chaos in all subsequent revisions and possibly invalidating all working copies.

The project has plans, however, to someday implement an svnadmin obliterate command which would accomplish the task of permanently deleting information. (See issue 516.)

In the meantime, your only recourse is to svnadmin dump your repository, then pipe the dumpfile through svndumpfilter (excluding the bad path) into an svnadmin load command. See chapter 5 of the Subversion book for details about this.

http://subversion.apache.org/faq.html#removal

Barbarous answered 26/8, 2011 at 9:13 Comment(4)
Great, thanks for the info, that sounds like more work than it's worth for the problem I'm trying to fix. I think I'll need to do an update, checkout the revision that I need to role back to in a separate folder. Export those files over my checked out trunk code, resolve any problems and check back in.Crucifix
Not the cleanest of solutions thoughCrucifix
@Mantisimo: Martin gave this answer because you asked "to remove a revision as if it never existed". What he thought was thus: it shouldn't even appear in the log history. If that's what you want, his answer is the right one. If you just want to undo a commit, then my solution is the right one.Wiltshire
If this is the latest revision and this issue is part of creating a mirror of svn using svnsync there is hope. As per subversion.1072662.n5.nabble.com/… Remove /your_repo_location/db/revs/[rev#] Remove /your_repo_location/db/revprops/[rev#] Change rev# in /your_repo_location/db/current back to [rev#-1]Althorn
H
4

You can move the trunk to another branch (backup) and copy the correct revision back to trunk

svn mv trunk https://svn_path/tags/trunk_broken
svn cp -r revNo http://svn_path/tags/trunk_broken http://svn_path/trunk

Please note the revision number will increment and all changes will be displayed in svn log.

Hoehne answered 8/5, 2013 at 10:47 Comment(0)
P
0

You can create a dump of the current repository and skip the bogus Revision in the dump. You can then load the dump to a new repository on the same server or on a different one.

Panhellenism answered 29/8, 2011 at 0:24 Comment(0)
R
0

I recommend leaving the revision if you don't have a real reason (Shortage in space for example) to remove it. This is the main job of the SVN server, to keeps changes.

Resa answered 20/12, 2013 at 8:37 Comment(1)
this is just your recommendation and observation but it doesn't particularly answer the actual questionFruition

© 2022 - 2024 — McMap. All rights reserved.