Question

I want to remove the last revision (or last n revisions) from a repository.

How to do it?

Is it possible to remove the svn revision files from project/db/revs/ and from project/db/revprops/ ?

Was it helpful?

Solution 2

Check SVNBook: Repository Maintenance.

svnadmin dump <path-to-repository> -r 0:99 > mydump.dump

Where 99 is your N-1 number. This way you create a dump of your repository from 0 to 99 revision and can load into a new fresh repository with svnadmin load.

OTHER TIPS

I just tried to do exactly what you suggested in your question and it worked!

First, you remove the last revision from db/revprops and db/revs. Then you also have to decrement the numbers in db/current and db/txn-current

If any other developer already had checked out the last revision then they must check out again fresh. Having checked out an older revision seems to be ok.

There will be no unforseen sideeffects because I made a diff with before and after and the databases were identical (after commit & removing the last rev).

But I think it is very clear that you can only remove revisions at the end of the chain. Removing a revision from in the middle can screw up the deltas between the revisions.

You dont need to be an expert in svn database structure to do such simple things, as bahrep suggested in the comments

Why do you want to remove the last revision? Does it contain data that may be sensitive in nature, and should never be seen by anyone, or was the last revision a real stinker?

As pointed out, you can do a dump and load via svnadmin. It takes your repository down and is usually more of a pain than it is worth. However, it does make it seem as that last revision never took place. It's the only way to completely rub out the revision. Something you might do only when information in that revision is something that's very proprietary or something that could get your company sued.

An easier way is to simply revert that bad revision. You can revert the last revision (or any revision) via the svn merge command:

$ svn merge -c -$rev_to_remove .

The old removed revision's history will still be there, and it will be accessible if a user knows Subversion well enough. But, the state of the repository will be back where it was before that last fatal revision.

Generally, removing a revision involves creating a new copy of the repository with the particular revision removed. If it's a small check-in, I'd say get the previous version, move those files to the side, get latest, then copy the previous files on top and check back in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top