Case folding collision in Mercurial (WinXP)

Adrian Buehlmann adrian at
Mon Jun 30 02:04:36 CDT 2008

On 24.06.2008 22:53, Matt Mackall wrote:
> On Tue, 2008-06-24 at 12:03 -0700, Dan Craft wrote:
>>> I'm not quite clear what
>>> you're trying to do, but you should be able to
>>> 'manually revert' by either cloning your repo and copying files or using
>>> 'hg cat'. Alternately, you can use hg diff to capture your changes,
>>> check out an old revision, then apply (most of) the diff.
>> Thanks, Matt.  A couple more answers will help me on my way.
>> Did you mean clone using 'hg clone'?
> Yes. Clone -U will skip the checkout.
>>   What do I lose if I just copy the repository via filesys commands?
>> (Once I have this sandbox, I can just try stuff.)
> Nothing, provided you copy all the files.
> Here's a little trick I came up with:
> - make a repo with 'a' and 'A' on Linux
> - hg clone -U to Windows (actually Wine in my case)
> - cd <repo>
> - hg debugsetparents <bad revision>
> - hg debugrebuildstate
> - hg rm -A A # mark missing file as deleted
> - hg ci -m"fix case collision"
> - hg manifest tip # confirm that the collision is gone
> - hg co -C tip # get a clean checkout
> The trick is to use debugsetparents and debugrebuildstate to get a
> working directory that thinks its at the revision we can't check out.
> Then we record a deletion for the unwanted file. When we commit, commit
> will only record the deletion we made via hg rm.

I've tested this with Mercurial dbb00e91c327 on Windows XP SP3.
Works fine.

Matt also wrote page on the wiki describing this trick:

(linked from

> hgc -q version
--- running hg from W:\hg-crew
Mercurial Distributed SCM (version dbb00e91c327)

> hgc clone -U --debug
--- running hg from W:\hg-crew
destination directory: casecollision
sending heads command
requesting all changes
sending changegroup command
adding changesets
add changeset 26071ae38a5c
add changeset b567297e23fc
adding manifests
adding file changes
adding A.txt revisions
adding a.txt revisions
added 2 changesets with 2 changes to 2 files
updating the branch cache

> cd casecollision

> hgc log
--- running hg from W:\hg-crew
1[tip]   b567297e23fc   2008-06-30 02:39 -0400   test
  added A.txt

0   26071ae38a5c   2008-06-30 02:38 -0400   test
  added a.txt

> hgc debugsetparents tip
--- running hg from W:\hg-crew

> hgc debugrebuildstate
--- running hg from W:\hg-crew

> hgc rm -A A.txt
--- running hg from W:\hg-crew

> hgc ci -m"fix case collision"
--- running hg from W:\hg-crew

> hgc manifest tip
--- running hg from W:\hg-crew

> hgc co -C tip
--- running hg from W:\hg-crew
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

More information about the Mercurial mailing list