Search code examples
visual-studio-2010visual-studiomercurialtortoisehgvisualhg

VisualHG marks files with an [R] but TortoiseHg still removes/adds the files when committing


I'm using Visual Studio 2010 with VisualHG and TortoiseHg. I've noticed that if I move or rename a file using the Solution Explorer, a little [R] appears next to the file, which I assume indicates "renamed". However, if I go to commit my changes in TortoiseHg, it doesn't perform a rename--it deletes the old file and adds the new one. This causes all the history for the file to be lost (and bloats the repo unnecessarily).

Is there any way to get this to work properly? There's really very little benefit to using VisualHG if it's not going to coordinate file renames properly with TortoiseHg.

Also, I should mention that TortoiseHg has a "Detect Copies/Renames in Solution" dialog, but I can't seem to get it working. First, I can't seem to find any button or menu item in the TortoiseHg Workbench to launch it. Second, if I launch if using the terminal by entering thg guess, no path appears in the Unrevisioned Files box (and there's no apparent way to add one). I made sure I was navigated to the correct directory (my solution directory, which contains my .hg repo) when I tried this. I also tried thg guess solution_directory_path, but that made no difference. If this dialog is a possible solution to my problem, how do you actually use it?

Edit

I finally figured out that you can access the "Detect Copies/Renames in Solution" dialog by right clicking the solution folder in Windows Explorer, and selecting TortoiseHg > Guess Renames. When I do this, however, again, no path appear in the Unrevisioned Files box, so I still can't get started with this dialog. (I.e., I can't even perform step 1 in these instructions.)

Edit 2

I found a bug report on the VisualHG CodePlex issues page that I think explains the problem I'm having: https://visualhg.codeplex.com/workitem/99. I'm kind of surprised it hasn't gotten more votes, though.


Solution

  • After further investigation, I realize that, even though the files were shown as removed/added in TortoiseHg Workbench, they in fact were renamed correctly.

    If you click a file with a "+" next to it in the Workbench, if that file was in fact a rename, the header for the code window will show something like this:

    Project/Folder/RenamedFile.cs (renamed from Project/Folder/OriginalFile.cs)

    After reading a bit more about what Mercurial is really doing, it sounds like it actually is deleting and adding, it's just that the added file maintains a reference to the original, so you can still view the history across renames.

    I'm not sure if this explains the problems I was having with "Detect Copies/Renames in Solution", but I'm now satisfied that renames are being handled properly.