using visual svn and tortoise svn here
I renamed my file
I notice it say add and delete which to me means history may be erased?
What is the best way to rename a file without losing history in subversion?
using visual svn and tortoise svn here
I renamed my file
I notice it say add and delete which to me means history may be erased?
What is the best way to rename a file without losing history in subversion?
The file's history will not be erased. Previous commits won't be affected. However, you can use svn move
to properly move the file.
The history is not erased by doing a rename from the TortoiseSVN Context Menu. If you want to see the changes from before the rename, make sure you don't use the --stop-on-copy flag when looking at the change log:
svn log -v -r 0:N --limit 100 [--stop-on-copy] PATH
or
svn log -v -r M:N [--stop-on-copy] PATH
see here for reference: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-cli-main.html
The history won't be erased, but you will lose history tracing, as it would seem to be two unrelated files.
From TortoiseSVN docs:
If you want to do a simple in-place rename of a file or folder, use Context Menu → Rename... Enter the new name for the item and you're done.
Repairing File Renames
Sometimes your friendly IDE will rename files for you as part of a refactoring exercise, and of course it doesn't tell Subversion. If you try to commit your changes, Subversion will see the old filename as missing and the new one as an unversioned file. You could just check the new filename to get it added in, but you would then lose the history tracing, as Subversion does not know the files are related.
A better way is to notify Subversion that this change is actually a rename, and you can do this within the Commit and Check for Modifications dialogs. Simply select both the old name (missing) and the new name (unversioned) and use Context Menu → Repair Move to pair the two files as a rename.
Many other cases are covered.
Update
The history is lost when Subversion doesn't know it's a rename, like this:
To preserve file history, you need to use the Rename option from the contextual menu (or from the command line). IF you already renamed the file then:
So, to resume, in the commit dialog added (+) means that history will be preserved, and added means loosing the the history. In both cases, the old file name will appear as deleted.
Update 2
When I say that history is lost, please understand that the previous information still exists, but it won't be present in the log of the current file name, and you must manually track it (which is not quite a pleasant thing to do).
A delete and add with history is the expected thing to happen when renaming a file in Subversion. History is not lost.
VisualSvn and AnkhSvn both capture the events from Visual Studio that a file is being renamed, and do the right thing.
For file operations like moving and renaming I normally prefer to use the TortoiseSVN Repo Browser, followed by a local SVN Update. Of course that's only appropriate if you want your operation to be committed to the repository straight away.