[PATCH 2 of 3] Eliminate normpath from foldmap calls

Petr Kodl petrkodl at gmail.com
Tue Sep 30 13:54:19 CDT 2008


# HG changeset patch
# User Petr Kodl <petrkodl at gmail.com>
# Date 1222800726 14400
# Node ID 4c4f0e0856051aaee373ede840315a05c8e1563e
# Parent  50c9963d5a5ed98bf1046d0ca897d00b0cedc4b2
Eliminate normpath from foldmap calls.
Normcase already takes care of upper/lower case and /->\ conversions.

What's left for normpath is folding of a/../a sequences but this should
be either done consistently on both non-folding and folding code path
or not at all, otherwise we are introducing inconsistent behavior between the
two that has nothing to do with case folding.

Second argument against it - normpath being pure Python function is very slow -
as much as 50% of time is spend just inside normpath call on my repository.

diff -r 50c9963d5a5e -r 4c4f0e085605 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Sep 30 14:33:07 2008 -0400
+++ b/mercurial/dirstate.py	Tue Sep 30 14:52:06 2008 -0400
@@ -41,7 +41,7 @@
         elif name == '_foldmap':
             _foldmap = {}
             for name in self._map:
-                norm = os.path.normcase(os.path.normpath(name))
+                norm = os.path.normcase(name)
                 _foldmap[norm] = name
             self._foldmap = _foldmap
             return self._foldmap
@@ -98,7 +98,7 @@
             if self._checkcase:
                 self.normalize = self._normalize
             else:
-                self.normalize = lambda x, y=None: x
+                self.normalize = lambda x, y=False: x
             return self.normalize
         else:
             raise AttributeError(name)
@@ -350,7 +350,7 @@
         except KeyError:
             self._ui.warn(_("not in dirstate: %s\n") % f)
     def _normalize(self, path, knownpath=False):
-        norm_path = os.path.normcase(os.path.normpath(path))
+        norm_path = os.path.normcase(path)
         fold_path = self._foldmap.get(norm_path, None)
         if fold_path is None:
             if knownpath or not os.path.exists(os.path.join(self._root, path)):


More information about the Mercurial-devel mailing list