views:

1509

answers:

4

Please note: This is a question about the Eclipse plugin Subversive, and not about Subversion itself. Please do not change the title to be about 'Subversion'.

So I deleted a file that I really shouldn't have.

I've found various approaches to restoring the file outside of Eclipse/Subversive, but I was wondering if there was a best/easiest-to-use/history-restoring way to restore the file using the Subversive tool.

+2  A: 

you could switch to revision where this file was exist. Edit/copy this file and switch back to the head revison and commit it here.

Also you could merge changes beetween two revisons - head and last revision file was exist in repository and apply changes to your working copy.

waney
A: 

I guess you're hoping to not resort to the command line but in case it's useful as a last resort, see this question for how to do it from the command line: http://stackoverflow.com/questions/497670/whats-a-simple-way-to-undelete

dreeves
+3  A: 

If you have already submitted the remove then it's now time to roll back to the earlier version. In Subversion you do that with "svn merge", where you merge "backwards" from the current to the previous version.

Say you did this:

$ svn rm file.txt
$ svn ci -m "don't need that file"
Committed revision 1325.

Now you want to undo this and restore the old revision 1324, i.e. the state just before the remove (the dot is for 'current directory'):

$ svn merge -r1325:1324 .

If you are unsure you can do a dry-run first, where svn will print the output of the command, but not actually do anything:

$ svn --dry-run merge -r1325:1324 .

The result should indicate that the file is being added (again):

A file.txt
+2  A: 
  1. Select the folder in the project that contained the deleted files.
  2. Right click, select Team > Merge...
  3. On the URL tab, set the URL to the server URL for the same folder.
  4. In Revisions, select Revisions and enter a range that includes the deletion, e.g. 1000-1001, or use the Browse button to select them.
  5. In Revisions, enable Reversed merge
  6. Click Preview and check that it shows an Added entry for the files you plan to restore.
  7. Click OK - Eclipse switches to SVN Merge in the Synchronize view.
  8. In the Synchronize view, right click the files you want and select Accept
  9. In the Synchronize view, use the Synchronize SVN icon to switch from SVN Merge to SVN, where you can see the restored file as an outgoing change.
Peter Hilton