Losing SVN history on files during refactoring
Asked Answered
S

4

13

During some refactoring, I'm moving files around. Obviously SVN sees this as deleting the file and creating a new one since the IDE doesn't trigger an SVN rename/move operation. However I thought the SVN server would be smart enough to detect it, but this is not proving to be the case... not all the time anyway. I'm using Tortoise SVN and I am unchecking the "stop on copy/rename" button.

Is this expected? Is there a way round it? Should I move files using Tortoise SVN shell commands rather than letting the IDE do a regular file move?

Also, is it possible to manually force SVN to link two files as the same entity if it doesn't know? Like tell it "/com/john/test.tct is the same as /com/john/test/file.txt"?

Selfliquidating answered 16/10, 2010 at 14:3 Comment(0)
F
25

The SVN way to do this is actually to have SVN rename the file (svn move or using TortoiseSVN's "Rename"). However, if you absolutely must have some external tool to perform the rename operation, you can use TortoiseSVN to repair the move operation. The following will tell SVN that the new file is actually the renamed old one:

  1. Open the "Check for Modifications" Window.
  2. Mark both the old file name (listed as missing) and the new one (listed as unversioned)
  3. Right click this selection and chose "Repair Move".

Note: I'm typing this from memory. It might not be fully correct. And there might be other ways to do this (like marking the files in the explorer).

If you already lost the history on a file where you miss it badly, you could resurrect the old file (you do this by svn copying an old revision's version into its old place), merge the new file's history into it, then delete the new file, and svn move the old file to the new file's name.

Fortran answered 16/10, 2010 at 16:37 Comment(5)
Thanks, very interesting. I don't think it's feasible to do all this through the SVN client, because many refactoring operations automatically do this and you'd then face manually updating a project/build file which really just moves the problem. I'll certainly try that Tortoise thing... but presumably this must wrap standard SVN operations, what are they?Selfliquidating
@John: It might be as simple as wrapping svn move, but I have never tried what svn move source target does when source had already been renamed to target, so it might be more complicated than that. I don't know.Fortran
See here for a detailed description on how to repair renames/moves: tortoisesvn.net/node/351Agro
@Stefan: Thanks for that link and thank you a lot for all the time you put into that project!Fortran
Stefan's link is broken, I think this is the new link: tortoisesvn.net/repairmoves.htmlIncardinate
C
2

You could install the (free) visual studio add-in AnkhSVN. This will track your file-renames and you won't lose the history in subversion.

File renames are tracked by the subversion client. If you rename files without using the subversion client (using windows explorer or visual studio solution explorer instead of TortoiseSVN or AnkhSVN), then subversion won't recognise the rename operation (only a delete and an add operation).

BTW: using AnkhSVN gives you some other advantages, such as the displaying the subversion status of files directly in the solution explorer.

Alternatively there's also VisualSVN, which is comparable to AnkhSVN, but is commercial.

Colpin answered 16/10, 2010 at 14:6 Comment(2)
This isn't Visual studio... it's actually a Flex project. So is this a common problem then? I've actually used VisualSVN on VS, it's pretty good but I didn't know it tracked moves.Selfliquidating
@John: Oops, sorry. But yes this is a common problem (as I wrote). You have to do your file-renaming using a subversion client (such as TortoiseSVN's rename command). I don't know if there is a similar add-in for the flex IDE.Colpin
F
1

Tortoise defaults to Stop on copy when viewing logs.

If you uncheck that box on the log viewer, then you'll be able to see the entire history of the files/directories.

Firstfoot answered 9/10, 2015 at 9:45 Comment(0)
S
0

If you rename your repo project and did bunch of renaming (classes etc), you might notice that "Show Log" will no longer show all the history that existed before the rename.

But, dont worry, it is not lost. It is just a flag. To show the history again, right click on your project > TortoiseSvn > Show Log, then uncheck the checkbox "Stop on copy/rename" in the dialog that opens and all the history will show up again:

enter image description here

Sommer answered 9/5, 2022 at 20:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.