Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent SVN restoring deleted files

I work in a team of developers and we don't have exactly separated code. So when I work on something for about a week, I need to do an update before i commit my changes. But when I do so, then all deleted files are restored. I know there is SVN delete operation, but it is annoying to do it for every deleted file or directory.

Is there any trick, how prevent this feature?

like image 839
Michal Krasny Avatar asked Aug 04 '14 11:08

Michal Krasny


2 Answers

So, this is not basically a new answer but none of the existing seemed to fit to your exact question (and the problem I experience often).

Here is my approach: If you deleted files and don't want them to get restored during the neccesary update:

  1. Use TortoiseSVN function "Check for modifications"
  2. Order the list by Status
  3. Select all files with status "missing"
  4. Right click, delete

Of course this is "SVN delete", but this way you won't have to do it at the time you actually delete the files and are able to mark all of them in a batch.

like image 198
Tarnschaf Avatar answered Sep 18 '22 14:09

Tarnschaf


There are two kinds of deletes here.

  1. Delete from file system (rm or delete).
  2. Delete from revision control (svn delete).

Make sure you know which kind you are doing. If you are deleting from the file system (local machine) only, then when you ask to update to the latest in your repository, you should get the file back.

If you are deleting from revision control, then it is a svn change operation, and will not apply to the repository until you run svn commit. After that as others update, svn will remove the file from their repositories.

Note that this does not mean that it is impossible to get a copy of the file. SVN keeps a full history of every revision, so if you request the non-current revisions that have a copy of the file, you will get a copy of the svn deleted file as it was in that revision.

In the rare case you really want the file gone from the historical records too, you need to do some scripting. Basically, you will be creating a new repository which mimics the old one (minus the file). To do this

For each revision number from 1 to current.

  1. get the files from the old repository.
  2. remove the offending file.
  3. commit to the new repository

Keep in mind that this can be a bit difficult to do well, as you will need to come up with solutions to preserve the meta-data, like file permissions, commit messages, svn properties, commit times, and commit user names.

I highly recommend against rebuilding your history this way, unless there is some globally overriding reason to do so, like a court order.

like image 38
Edwin Buck Avatar answered Sep 22 '22 14:09

Edwin Buck