Search code examples
macosmercurialkiln

How to solve a Mercurial case-folding collision?


I use Mercurial as source control with the main repository managed on KILN. At one point in time I changed my iOS project name from WeatherTimeMachine to weathertimemachine. This resulted in a case change of several files and folders:

  • WeatherTimeMachine.xcode
  • WeatherTimeMachine_Prefix.pch
  • WeatherTimeMachine-Info.plist

In the meantime I've added a tag to a revision in KILN... So I now have:

  • a head in KILN
  • a head on my local repo with case changes

When trying to merge I get the following error message: "Mercurial case-folding collision"

How can I fix this?


Solution

  • I have found some information here: FixingCaseCollisions, but somehow this did not work for me. Here is how I managed to solve this issue:

    Make a copy of your existing repository folder (for safety). For example:

    • cp -r WeatherTimeMachine WeatherTimeMachineCopy

    Fool mercurial into thinking the problematic revision is the current tip:

    • hg debugsetparents <bad revision>
    • hg debugrebuildstate

    Remove the files which are causing the problem (-f is required to force the removal). Here is an example:

    • hg rm -A -f WeatherTimeMachine-Info.plist

    Once all problematic files have been removed, commit the changes

    • hg ci -m "fixed collision-folding issue" -u michael

    Then restore mercurial to the proper revision

    • hg debugsetparents tip
    • hg debugrebuildstate

    After this the merge is possible and the problem is gone.

    And now I can happily resume working with MacHg to manage my Mercurial repository and push my change sets to KILN.