##// END OF EJS Templates
i18n: use UTF-8 string to lower filename for case collision check...
FUJIWARA Katsunori -
r14980:28e98a8b stable
parent child Browse files
Show More
@@ -0,0 +1,43
1 run only on case-insensitive filesystems, because collision check at
2 "hg update" is done only on case-insensitive filesystems
3
4 $ "$TESTDIR/hghave" icasefs || exit 80
5
6 setup repository, and target files
7
8 $ HGENCODING=cp932
9 $ export HGENCODING
10 $ hg init t
11 $ cd t
12 $ python << EOF
13 > names = ["\x83\x41", # cp932(0x83, 0x41='A'), UNICODE(0x30a2)
14 > "\x83\x5A", # cp932(0x83, 0x5A='Z'), UNICODE(0x30bb)
15 > "\x83\x61", # cp932(0x83, 0x61='a'), UNICODE(0x30c2)
16 > "\x83\x7A", # cp932(0x83, 0x7A='z'), UNICODE(0x30db)
17 > ]
18 > for num, name in zip(range(len(names)), names):
19 > # file for getting target filename of "hg add"
20 > f = file(str(num), 'w'); f.write(name); f.close()
21 > # target file of "hg add"
22 > f = file(name, 'w'); f.write(name); f.close()
23 > EOF
24
25 test filename collison check at "hg add"
26
27 $ hg add --config ui.portablefilenames=abort `cat 0`
28 $ hg add --config ui.portablefilenames=abort `cat 1`
29 $ hg add --config ui.portablefilenames=abort `cat 2`
30 $ hg add --config ui.portablefilenames=abort `cat 3`
31 $ hg status -a
32 A \x83A (esc)
33 A \x83Z (esc)
34 A \x83a (esc)
35 A \x83z (esc)
36
37 test filename collision check at "hg update"
38
39 $ hg commit -m 'revision 0'
40 $ hg update null
41 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
42 $ hg update tip
43 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -7,7 +7,7
7 7
8 8 from node import nullid, nullrev, hex, bin
9 9 from i18n import _
10 import scmutil, util, filemerge, copies, subrepo
10 import scmutil, util, filemerge, copies, subrepo, encoding
11 11 import errno, os, shutil
12 12
13 13 class mergestate(object):
@@ -92,7 +92,7 def _checkcollision(mctx):
92 92 "check for case folding collisions in the destination context"
93 93 folded = {}
94 94 for fn in mctx:
95 fold = fn.lower()
95 fold = encoding.lower(fn)
96 96 if fold in folded:
97 97 raise util.Abort(_("case-folding collision between %s and %s")
98 98 % (fn, folded[fold]))
@@ -6,7 +6,7
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from i18n import _
9 import util, error, osutil, revset, similar
9 import util, error, osutil, revset, similar, encoding
10 10 import match as matchmod
11 11 import os, errno, re, stat, sys, glob
12 12
@@ -46,10 +46,10 class casecollisionauditor(object):
46 46 self._abort = abort
47 47 self._map = {}
48 48 for f in existingiter:
49 self._map[f.lower()] = f
49 self._map[encoding.lower(f)] = f
50 50
51 51 def __call__(self, f):
52 fl = f.lower()
52 fl = encoding.lower(f)
53 53 map = self._map
54 54 if fl in map and map[fl] != f:
55 55 msg = _('possible case-folding collision for %s') % f
General Comments 0
You need to be logged in to leave comments. Login now