Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between a 'delete' and 'unversion' in SVN?

I have a file that had been under revision control in SVN (I use tortoiseSVN). This file has become obsolete, thus I no longer want it to be in a working copy of my repo. However, it would probably be good to retain the history of that file.

I essentially want to 'delete' this file such that it is no longer tracked or 'versioned'. I have the option to either 'delete' this file, or 'unversion' this file.

What is the difference between 'delete' and 'unversion'. What the use cases for each command?

like image 876
Izzo Avatar asked May 16 '17 15:05

Izzo


People also ask

What is svn delete?

svn delete (del, remove, rm) — Delete an item from a working copy or the repository.

How do I delete everything from svn?

To remove a file from a Subversion repository, change to the directory with its working copy and run the following command: svn delete file… Similarly, to remove a directory and all files that are in it, type: svn delete directory…

Can I delete .svn folder?

There is only one . svn folder, located in the base of the working copy. If you are using 1.7, then just deleting the . svn folder and its contents is an easy solution (regardless of using TortoiseSVN or command line tools).


1 Answers

Removing a file from svn, does not delete its revision history.
Apparently deleting the history is possible [SO]: Delete file with all history from svn repository.

To make things easier let's consider the following analogy.
From svn's PoV, just like:

  • a (source) file consists of:
    • a sequence of items: lines (of code)

Same way:

  • a folder consists of:
    • a sequence of items: its children:
      • (sub)folders
      • files

Let's say that we have an svn file:

  • In revision M, a line of code (let's make it the last one to better illustrate the example) in that file was modified
  • In revision N (> M), that line was deleted

The situation is as follows:

  1. For file revisions greater than N, the line won't be present
  2. For file revisions between M and N, the line will have its last content
  3. For file revisions lower than M, the line will have its old content
  4. ....

Same thing would happen if removing a file (from its parent folder perspective).

Now, back to your question: on my TortoiseSVN (v1.9.5):

  • I have a Delete option
  • I don't have an Unversion option, but
  • I do have a Delete (keep local) option - which is (a better name maybe for) Unversion. In terms of command line, this is equivalent to svn delete --keep-local

After performing one of the actions on a file, that file will no longer be tracked by svn, but as opposed to Delete (where the file is also removed from the Working Copy/disk), Unversion will leave it on the disk just like the user would have manually copied it there (a subsequent svn st will "see" the file as not under version control: the first column will be a question mark (?) as described on [SVNBook]: svn status).

[TortoiseSVN]: Deleting, Moving and Renaming contains very little official info.

Personally, I see no use of keeping the local file except when fixing an error, e.g. removing previously committed items that don't belong in the repository (user specific) like:

  • Eclipse: .classpath, .project
  • PyCharm: .idea
  • VStudio: .vcxproj.user

Quote from [SVNBook]: svn delete:

Use the --keep-local option to override the default svn delete behavior of also removing the target file that was scheduled for versioned deletion. This is helpful when you realize that you've accidentally committed the addition of a file that you need to keep around in your working copy, but which shouldn't have been added to version control.

like image 187
CristiFati Avatar answered Sep 28 '22 04:09

CristiFati