I\'m using VS2013 Update 4 with TFS 2013 Update 4. In Source Control Explorer, whenever I move a file from one folder to another I can see that the file\'s history is preser
I came to this issue from this question.
The issue exists since TFS2010 and is not only a problem for renamed or moved files, but for renamed or moved folders as well. The worst is if you a renamed branch and then look at the folder history. Then you only find your rename changeset.
Here you can see the reaction of MS on this task. Basically they say that they are not doing it because it is a lot of work and makes the history slower.
I could not live with this fact and programmed a fix for this. Recursive history selection happens in SP dbo.prc_QueryHistory. I changed the SP and added the following functionality:
The effect is a slower history (especially if you do it on the root of a deep folder tree), but the issue is fixed. And I rather live with a slow history than with an incomplete.
I could provide you the SP I wrote, but I am not sure if I would be allowed to publish it here, as it contains MS protected code. (And of course I cannot guarantee that the fix will persist when updating the system. - I wrote my SP on a TFS 2013 SP3.)
Update: I asked MS for permission to publish my fix (2nd link in my post)
When a file is renamed correctly, the History is not "Gone", it's associated to the "old name" instead. A rename that is done the right way (tracked as a rename and not as an delete+add) has a drilldown option to view the "older" history:
When a rename is done outside of the Source Control Explorer (or from a very old version of the Source Control Explorer (e.g. VS 2008)) or outside the Solution Explorer, then the change will be detected as two individual actions, one delete and one add. You can use the "Pending Changes" window to promote these to a rename so that the history is preserved:
On the commandline this can only be accomplished using "tf rename" and "tf move". Using the standard "mv" and "ren" commands will fail to preserve the history.
Below is a further example of using all the different methods and clearly showing that history is preserved by looking at the history of the current file name:
As mentioned in the comments, history is stored in the Team Project that contains the items revision. When branching/moving across projects your history will be spread across these projects. Should you delete a Team project than all history that was accumulated in that project will be lost.
I don't think jessehouwing fix works for folders. In fact if you use Source Control Explorer of VS 2012+, the move of folders preserves the files history (shows recursive in VS), but not for folders. Folders history is flat.
The solution to this problem:
Please find my tf move
experience
There was main
branch in the TFS. I've created main-rest
on the same hierarchy level as main. Then I tried to move main-rest
to another subfolder (to move experimental branches from the $ root to the subfoler.
I've removed local folder mapping and executed
tf move $/projectName/main-rest $/projectName/experimental/main-rest
The command listed all files in the branch in the output. Then I've committed my changes.
It looks fine, but * there is no branch folder history any more * merge does not see the changesets to merge
There was a possibility to merge from the main-rest
to the main
branch before movement. It is still available but no changesets to select when merging.
There is only one "moved" changeset in the "merge selected changeset only" option. It has happened after the main-rest
was moved to the experimental
subfolder.
I hope that it is possible to merge the whole master-rest
branch (but it is not right time to test)
I've used tf.exe command line utility that is shipped with the VS2017 (patched with the latest update available for today). Source code is hosted on the cloud tfs (https://dev.azure.com)
Regards