[PATCH 1 of 2] distat: regression reported in issue 1286

Petr Kodl petrkodl at gmail.com
Mon Sep 29 11:46:14 CDT 2008


# HG changeset patch
# User Petr Kodl <petrkodl at gmail.com>
# Date 1222706179 14400
# Node ID 7e5c9354cef165d536ffaf21e04f97fea393cff6
# Parent  9e6d6568bf7a21f900273de027d8975a4e0cecae
distat: regression reported in issue 1286

diff -r 9e6d6568bf7a -r 7e5c9354cef1 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Sep 29 12:12:53 2008 +0200
+++ b/mercurial/dirstate.py	Mon Sep 29 12:36:19 2008 -0400
@@ -98,7 +98,7 @@
             if self._checkcase:
                 self.normalize = self._normalize
             else:
-                self.normalize = lambda x: x
+                self.normalize = lambda x, y=None: x
             return self.normalize
         else:
             raise AttributeError(name)
@@ -350,13 +350,16 @@
         except KeyError:
             self._ui.warn(_("not in dirstate: %s\n") % f)
 
-    def _normalize(self, path):
+    def _normalize(self, path, defpath = None):
         norm_path = os.path.normcase(os.path.normpath(path))
-        if norm_path not in self._foldmap:
+        fold_path = self._foldmap.get(norm_path, defpath)
+        if fold_path is None:
             if not os.path.exists(os.path.join(self._root, path)):
-                return path
-            self._foldmap[norm_path] = util.fspath(path, self._root)
-        return self._foldmap[norm_path]
+                fold_path = path
+            else:
+                fold_path = self._foldmap.setdefault(norm_path,
+                                util.fspath(path, self._root))
+        return fold_path
 
     def clear(self):
         self._map = {}
@@ -505,6 +508,7 @@
                             results[nf] = None
 
         # step 2: visit subdirectories
+        sep = os.sep
         while work:
             nd = work.pop()
             if hasattr(match, 'dir'):
@@ -515,7 +519,8 @@
             else:
                 entries = listdir(join(nd), stat=True, skip ='.hg')
             for f, kind, st in entries:
-                nf = normalize(nd and (nd + "/" + f) or f)
+                nf = nd and (nd + sep + f) or f
+                nf = normalize(nf, nf)
                 if nf not in results:
                     if kind == dirkind:
                         if not ignore(nf):


More information about the Mercurial-devel mailing list