Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell TortoiseSVN that a renamed file was renamed (not deleted and re-added)?

Using VisualSVN and TortoiseSVN here.

I've 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?

like image 931
zachary Avatar asked Feb 03 '10 21:02

zachary


People also ask

What does red exclamation mark mean in TortoiseSVN?

That means the Subversion status is normal. As soon as you start editing a file, the status changes to modified and the icon overlay then changes to a red exclamation mark. That way you can easily see which files were changed since you last updated your working copy and need to be committed.

How do I change a filename in SVN?

Renaming a file. Normally you can just use SVN Rename on the context menu. This is analogous to the Move command described in the Moving or Copying a file recipe. It is almost as if you are doing two separate steps: an Add operation with the new name and a Delete operation of the old name.

How do I rename tortoise in SVN?

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.

How do I tell TortoiseSVN that a file was renamed?

To tell TortoiseSVN that a file was renamed, right click the folder that contains it and choose Commit... or Check for modifications. You will see the old file name with status "missing" and the new file name with status "unversioned".

How do I move files in TortoiseSVN?

Then browse to the target folder, right click and choose TortoiseSVN→ Paste. For moving files, choose Context Menu→ Cutinstead of Context Menu→ Copy. You can also use the repository browser to move items around. Read the section called “The Repository Browser”to find out more. Do Not SVN Move Externals

How to delete and rename files and folders in subversion?

Next Deleting, Moving and Renaming Subversion allows renaming and moving of files and folders. So there are menu entries for delete and rename in the TortoiseSVN submenu. Figure 4.34.  Explorer context menu for versioned files Deleting files and folders Use TortoiseSVN→ Deleteto remove files or folders from Subversion.

How do I copy and move files in a tortoise repository?

Select the files you want to copy, right click and choose Context Menu→ Copyfrom the explorer context menu. Then browse to the target folder, right click and choose TortoiseSVN→ Paste. For moving files, choose Context Menu→ Cutinstead of Context Menu→ Copy. You can also use the repository browser to move items around.


3 Answers

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:

  • the old file name is aa.txt, and it's renamed by hand to bb.txt
  • the new file name bb.txt is added to subversion
  • in the commit dialog, aa.txt appears as missing and can be marked as deleted, and bb.txt appears as added
  • the result is that history is lost, SVN show log from the contextual menu will show only bb.txt

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:

  • the old file name cc.txt will appear as missing
  • check the Show unversioned files option to see the new file name dd.txt, which is marked as non-versioned
  • select both file names and choose Repair move from the contextual menu, which results in cc.txt being marked as deleted and dd.txt being marked as added (+)
  • after commit, history will be preserved, and in the log you will see both file names if you uncheck the Stop on copy/rename option.

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).

like image 157
alexandrul Avatar answered Oct 17 '22 16:10

alexandrul


Right Click on the file > TortoiseSVN > Rename.

like image 30
Fitzchak Yitzchaki Avatar answered Oct 17 '22 16:10

Fitzchak Yitzchaki


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

like image 5
Mike Sherov Avatar answered Oct 17 '22 14:10

Mike Sherov