[PATCH 2 of 3] Eliminate normpath from foldmap calls

Petr Kodl petrkodl at gmail.com
Tue Sep 30 12:38:23 CDT 2008


# HG changeset patch
# User Petr Kodl <petrkodl at gmail.com>
# Date 1222796272 14400
# Node ID 7f409f38ba44d344ba16755039bd69f4949a26f2
# Parent  42042444e12dbb1ed3a7bc5c76a3c6ab1a8a471c
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 42042444e12d -r 7f409f38ba44 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Sep 30 13:37:52 2008 -0400
+++ b/mercurial/dirstate.py	Tue Sep 30 13:37:52 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
@@ -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