Search code examples
mercurialcheckoutcase-sensitivecase-insensitive

Unable to fix Hg case-folding collision error with Mercurial's guide


Is there a problem with Mercurial's guide for fixing case-folding collisions or is there a problem with the way I am implementing the solution.

The solution as provided on the Mercurial wiki is as follows:

hg clone -U repo repair
cd repair

hg debugsetparents <bad revision>
hg debugrebuildstate 

At this point, Mercurial will think you have the bad revision checked out and all the files are missing (status '!'). To fix the repo, we simply have to do:

hg rm -A <file causing the collision> 

Now hg st should show the troublesome file in state 'R' and all other files in state '!'. Now we can check in our fix:

hg ci -m"fix case collision" 

To get all our files back, we just check out again:

hg co tip

The problem files are: SomeFile.bash and Somefile.bash. I originally had Somefile.bash and I would like it to now be SomeFile.bash. Also to note, version 157 is happy, no collision, but version 158 is where I have introduced the collision. The head of the repository is currently at revision 160.

I have implemented this solution as follows:

hg clone -U my-repo-url repair
cd repair
hg debugsetparent 160
hg debugrebuildstate
hg status (reveals that everything is 'missing' (!))
hg rm -A Somefile.bash (responds that SomeFile.bash has been removed, notice case change)
hg ci -m "Fixed the collision... I hope."
hg co tip

hg update -C tip

According to the guide, this should have removed the case-folding collision and brought the rest of the missing files back, yet another hg status reveals that everything is still missing (!).

Edit: By appending that last command (the update) to the existing commands, I was able to recover the missing files which solved the remainder of the problem.

Note: I had to use the most recent 'problem' version for <bad revision> to fix this problem (that was 160 in my case).


Solution

  • Try

    hg update -C tip
    

    That should bring the files back. If not, try reverting everything:

    hg revert -r tip -a