Search code examples
visual-studio-2010mercurialtortoisehgvisualhg

Strange case-sensitive directory name behaviour in Mercurial / TortoiseHG on Windows7


I have a TortoiseHG (2.3.2) repository containing a directory at the root called "cv2" on my Windows7 Ultimate (32 bit) machine. When I add a new file in different subdirectories of the "cv2", TortoiseHG is showing "cv2" as either "cv2" or "CV2" depending on the directory.

For example, if I add a file called "tom.cs" to the following directories, I get the following results in TortoiseHG:

Physical Directory                 TortoiseHG Filename
...\cv2\Common\tom.cs              cv2/Common/tom.cs
...\cv2\tom.cs                     CV2/tom.cs
...\cv2\WinClient\tom.cs           cv2/WinClient/tom.cs
...\cv2\WinService\tom.cs          CV2/WinService/tom.cs

I don't know when this started, but it has meant that I now have commits into both "cv2" and "CV2" resulting in two separate directories within the repository (not a lot I can do about that I guess).

The repository holds a single solution, with 3 projects in sub-directories ("cv2" is one of them, along with "cp2" and "NotificationService"). I've just discovered that the solution file had the directory name of "CV2" instead of "cv2". That has now been changed as it was stopping the "Diff" from working in Visual Studio... however it's been like that from the very start and has not been changed since the initial commit. Unfortunately I cannot remember if I have renamed the Windows directory in that time... it's possible I have.

Is there anything I do about this discrepancy of having either "CV2" or "cv2" depending on which directory it is? I have tried renaming the Windows directory via a command prompt without success. I was under the impression that Mercurial ignored case-sensitivity when being run on a Windows machine, but I guess I've been misinformed.

I am the only developer on the project, so there is no danger of messing up anybody else with any changes.


Solution

  • Yes, Mercurial ignores the file name case on case-insensitive filesystems, but it still has to store the filenames with some case in the repository.

    With Mercurial 2.2-rc (see the wiki for instructions on how to run a release candidate in Windows) you will be able to run

    hg rename CV2/tom.cs cv2/tom.cs
    

    to schedule a "rename" for the next commit. The file wont move on disk — since it's already in the right place for a case-insensitive file system — but the rename will be recorded in history and new checkouts will have the right case on the disk.

    There are more instructions in the wiki, including a caseguard extension that you can use to protect yourself in the future. However, this should mostly be fixed with Mercurial 2.2, which will have much more code for dealing with case folding issues compared to previous versions.