Question

I use SmartSVN as a frontend for Subversion. Occasionally, a source file that that is under repository control becomes redundant - I simply no longer need it. In such a case, I would like to delete it in the sense that updating the working copy no longer fetches the file from the repository. But I still want the file's history (i.e. the previously committed revisions) to remain in the repository.

If I remember correctly, SmartSVN's Remove command removes the file's history (I'm obviously hesitant to verify this). Please correct me if I'm mistaken. Otherwise: How can I achieve the desired effect?

EDIT: Using a dummy file, confirmed that Remove removes the file from SVN control completely, and its history is no longer visible. So the problem is real.

Was it helpful?

Solution

Subversion never completely deletes a file from the repository. In fact, this is a well requested feature.

You do a svn delete or svn rm, and the file is no longer in the working copy. However, it is definitely still there. What's probably is convincing you that the file has been permanently removed is that you're doing something like this:

 $ svn co http://repo/svn/project
 [...]
 $ cd project
 $ svn del foo.txt
 $ svn commit -m "Removed foo.txt"
 committed version 12345
 $ svn ls http://repo/svn/project/foo.txt
 No such file

This is true. File foo.txt is no longer in the most current revision of Subversion.

Maybe you did something like this:

You knew that the file isn't in revision 12345 because you removed it. However, let's look at revision 12344. The file should still be there in THAT revision:

 $ svn ls -r12344 http://repo/svn/project/foo.txt
 No such file

Look, revision isn't in revision 12344. Therefore, it has been permanently deleted.

Not so fast, Bunky. What you requested is revision 12344 of the file in the current revision of the repository layout. What you need to do is understand the difference between the file revision and the repository revision. This is called revision pegging, and can be one of the more difficult concepts in Subversion.

What you want to see is the file in the 12,344th revision of the REPOSITORY. To do that, you put a @ at the end of the repository URL:

 $ svn ls http://repo/svn/project/foo.txt@12344
 foo.txt

Now, we can see the file because it's in the 12,344th revision of that repository layout. If you need to undelete the file, you can always copy the revision of the file you want from the pegged revision of the repository layout:

 $ svn cp -r12344 -m"undeleting foo.txt" \
       http://repo/svn/project/foo.txt@12344 \
       http://repo/svn/project

This will copy revision 12344 of file foo.txt at the 12,344th revision of the repository to the current revision of the repository.

The easiest way to find files that have been deleted is to look at svn log:

 $ svn log -rHEAD -v http://repo/svn/project/foo.txt
 r12345 | dweintraub | [...]

 Removed foo.txt

 D  /project/foo.txt
 -----------------------------------------------------

I deleted file `foo.txt in revision 12345. Therefore, it still existed in revision 12344. Good to know if I need to undelete the file.

Yes, it might seem silly in this instance that I have to request the revision of the file and the Subversion layout because they're both the same. However, that's not always going to be the case. Files get moved around and copied, deleted, and undeleted. The version of the file I want might not be the same as the repository version I'm looking for.

OTHER TIPS

In SmartSVN:

Select File/Folder -> right click -> "Open in Repository Browser" -> right click on file/folder you want to remove -> "Remove..."

I accepted David W.'s answer - it correctly described the state of things from Subversion's point of view (command-line based). Since I'm using SmartSVN as a GUI front-end, I would like to add the appropriate information from this perspective.

To see the deleted file's history using SmartSVN,

  • Open a Repository Browser (as opposed to Project Window)
  • Issue the Repository | Show Revision command
  • Select the Revision radio button; then click the Select button
  • Select the repository revision you want to see

You will then see the file, provided it was present in the repository version you selected.

Note that the selected folder determines which files are displayed (there doesn't seem to be a way to display all files as in the Project Window), and also which repository revisions are displayed to select from.

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