--- a/mercurial/util.py Mon Oct 27 16:53:01 2014 -0500
+++ b/mercurial/util.py Fri Oct 24 11:39:39 2014 -0700
@@ -899,11 +899,8 @@
The root should be normcase-ed, too.
'''
- def find(p, contents):
- for n in contents:
- if normcase(n) == p:
- return n
- return None
+ def _makefspathcacheentry(dir):
+ return dict((normcase(n), n) for n in os.listdir(dir))
seps = os.sep
if os.altsep:
@@ -919,16 +916,15 @@
continue
if dir not in _fspathcache:
- _fspathcache[dir] = os.listdir(dir)
+ _fspathcache[dir] = _makefspathcacheentry(dir)
contents = _fspathcache[dir]
- found = find(part, contents)
+ found = contents.get(part)
if not found:
# retry "once per directory" per "dirstate.walk" which
# may take place for each patches of "hg qpush", for example
- contents = os.listdir(dir)
- _fspathcache[dir] = contents
- found = find(part, contents)
+ _fspathcache[dir] = contents = _makefspathcacheentry(dir)
+ found = contents.get(part)
result.append(found or part)
dir = os.path.join(dir, part)