Skip to content

Instantly share code, notes, and snippets.

@sr105
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sr105/1b562519f7cafbf25a14 to your computer and use it in GitHub Desktop.
Save sr105/1b562519f7cafbf25a14 to your computer and use it in GitHub Desktop.
e-mail about case colisions and revert
From: "Harvey Chapman" <hchapman-hg@3gfp.com>
Subject: revert and remove, filename case collision behavior
Summary:
1. Is "hg revert -a" supposed to give errors for filename case collision? I discovered that since it doesn’t, it makes for a nice way to clean up collisions on case-insensitive filesystems.
2. Also, hg remove acts a little odd when asked to remove a case collision filename. Examples below.
[ There would be an email here but the list server thinks it’s spam no matter how I send it and from where ]
I created a repo on a linux machine with two case conflicting filenames:
hg init test
cd test
touch file FILE apple
hg ci -Am “one apple and two files: file and FILE”
hg serve
I cloned it on OSX 10.10.1 using mercurial 3.2.2, and after the update failed as expected, I used the revert method mentioned in http://mercurial.selenic.com/wiki/ManualCheckout. I was surprised that revert doesn’t care about the collisions.
$ hg clone -U test_url mixed_case
$ cd mixed_case
$ hg manifest -r tip
FILE
file
$ hg update
abort: case-folding collision between file and FILE
$ hg identify
000000000000
$ hg revert -a -r tip
adding FILE
adding apple
adding file
$ hg debugrebuilddirstate -r tip
$ hg status -A
C FILE
C apple
C file
$ ls
apple file
The remove command seems to remove files using the filenames as a sort of pattern matching rather than an actual filename. Are these results correct?
Case 1: remove FILE
Result: removes FILE, deletes file
$ hg rm FILE
$ hg status -A
R FILE
! file
C apple
Case 2: remove file
Result: removes FILE and file, deletes file
$ hg rm file
removing FILE
$ hg status -A
R FILE
R file
C apple
Case 3: tried removing various mixed case spellings of file
Results: inconsistent
Remove Marked for Removal Extra output
1 fiLE file
2 FIle file not removing FIle: file is untracked
3 fiLe FILE not removing fiLe: file is untracked
4 fiLE FILE not removing fiLE: file is untracked
Note: 1 & 4 are the same pattern, but resulted in different removals
The only consistent method I’ve found for removing the files is this:
hg rm -Af -I file
Remove Marked for Removal
file file
FILE FILE
fiLE
FIle
fiLe
fiLE
If it helps others, this is how I cleaned up my real repo that had this problem where all of the duplicate files had identical content. I decided that I wanted to prefer uppercase names and used the following to remove the lowercase duplicates:
# sort manifest, ignoring case, in reverse (lowercase first),
# returning only duplicate names, again ignoring case
hg rm `hg manifest | sort -fr | uniq -id`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment