tags:

views:

377

answers:

2

By accident I called "svn import ..." in the wrong directory. Is there a sensible way to undo this mistake?

Googling I didn't find any useful answer, and the closest to my problem I found on stackoverflow was importing the correct data to the wrong place, whereas I imported the wrong data to the correct place.

And: the repository is NOT new, so deleting it is out of question.

It would be a kind of ironic, if I couldn't undo operations in a version control system. So can someone help me? (Thanks!)

EDIT: I got my repository stored in a Berkley Database, i.e., it's in the file system. Looking at the modification date of all files/directories and at the content of the just modified files I was able to work out what to do except for one thing: does anybody know what's the file txn-current is for? I guess it's connected to the transaction handling, but what's the meaning of its content (length is 2 bytes)?

EDIT 2: Thanks for both helpful answers. I accepted Martin's answer as it should provide the proper way of doing it (as I'm under time pressure I just deleted some files as hinted in my first EDIT ignoring the content of txn-current and live fine with until now). But check out the link Wim gave in his comment!

+6  A: 

You can't undo a commit directly, the only option for this is to do an svnadmin dump, remove the commit from the dumpfile (either by hand using a text editor, or using svndumpfilter, and svnadmin load it again.

If it's not a real problem that the data stays somewhere in the repository as an older revision, you can just svn delete it and commit something else instead.

Wim
Thanks, but there were some binaries in the wrong directory and I'd like to get rid of them. How could I remove the data using dump?
jug
An older version of the SVN book has some more info on using svndumpfilter: http://svnbook.red-bean.com/en/1.2/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svndumpfilter
Wim
Very useful link, thanks again! I'm on a different path in the moment (see the coming edit of my question), but if it doesn't work, I'll try svndumpfilter.
jug
+2  A: 

If there were no other commits since you imported your files, then you can easily delete the last revision using svn dump.

The following example is taken from this page:

  • (assuming revisions 1-125 are OK, 126 is that last revision, causing the problem)
  • make a backup of the repository, then dump the repository (except the last revision):
    • > svnadmin dump -r1:125 myrepo > my.dump
  • now create a new repository and load the dump:
    • > svnadmin create myrepo
    • > svnadmin load myrepo < my.dump
M4N