stat casefolding problem

Andrei Vermel avermel at mail.ru
Sat Aug 2 16:20:27 CDT 2008


> D:\distribs\mercurial\qqq>hg init
> D:\distribs\mercurial\qqq>echo 1>aaa.txt
> D:\distribs\mercurial\qqq>echo 1>BBB.txt
> D:\distribs\mercurial\qqq>hg add
> adding BBB.txt
> adding aaa.txt
> D:\distribs\mercurial\qqq>hg ci -m 1
> D:\distribs\mercurial\qqq>mv aaa.txt AAA.txt
> D:\distribs\mercurial\qqq>mv BBB.txt bbb.txt
> D:\distribs\mercurial\qqq>hg stat
> ? AAA.txt                    // aaa.txt and bbb.txt behave differently!

Patch below fixes the problem.

# HG changeset patch
# User Andrei Vermel <avermel at mail.ru>
# Date 1217691290 -14400
# Node ID 08ca3c1abb6108b79544361401982dfad70ee95f
# Parent  1f631cb17d32dceec02fe3637efe8b110cdd0ca7
Fix normalize fail on non-lowcase filename

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -344,11 +344,12 @@
             self._ui.warn(_("not in dirstate: %s\n") % f)
 
     def _normalize(self, path):
-        if path not in self._foldmap:
+        norm_path = os.path.normcase(os.path.normpath(path))
+        if norm_path not in self._foldmap:
             if not os.path.exists(path):
                 return path
-            self._foldmap[path] = util.fspath(path, self._root)
-        return self._foldmap[path]
+            self._foldmap[norm_path] = util.fspath(path, self._root)
+        return self._foldmap[norm_path]
 
     def clear(self):
         self._map = {}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stat_casefolding.patch
Type: application/octet-stream
Size: 938 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20080803/11680c6a/attachment.obj 


More information about the Mercurial-devel mailing list