changeset 6823:12081ea61a34

dirstate.walk: track normalized directory names
author Matt Mackall <mpm@selenic.com>
date Tue, 22 Jul 2008 13:03:15 -0500
parents 1e2850ed8171
children c3fb7dc51a4b
files mercurial/dirstate.py
diffstat 1 files changed, 7 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Tue Jul 22 13:03:14 2008 -0500
+++ b/mercurial/dirstate.py	Tue Jul 22 13:03:15 2008 -0500
@@ -456,11 +456,6 @@
             ignore = util.never
             dirignore = util.never
 
-        # self._root may end with a path separator when self._root == '/'
-        common_prefix_len = len(self._root)
-        if not util.endswithsep(self._root):
-            common_prefix_len += 1
-
         normpath = util.normpath
         normalize = self.normalize
         listdir = osutil.listdir
@@ -482,12 +477,11 @@
         # step one, find all files that match our criteria
         for ff in util.sort(files):
             nf = normalize(normpath(ff))
-            f = _join(nf)
             if nf in seen:
                 continue
 
             try:
-                st = lstat(f)
+                st = lstat(_join(nf))
             except OSError, inst:
                 keep = False
                 for fn in dmap:
@@ -513,13 +507,12 @@
                 continue
 
             if hasattr(match, 'dir'):
-                match.dir(normpath(f[common_prefix_len:]))
-            wadd(f)
+                match.dir(nf)
+            wadd(nf)
             while work:
-                top = work.pop()
-                entries = listdir(top, stat=True)
+                nd = work.pop()
+                entries = listdir(_join(nd), stat=True)
                 # nd is the top of the repository dir tree
-                nd = normpath(top[common_prefix_len:])
                 if nd == '.':
                     nd = ''
                 else:
@@ -529,18 +522,17 @@
                     names = [e[0] for e in entries]
                     hg = bisect_left(names, '.hg')
                     if hg < len(names) and names[hg] == '.hg':
-                        if isdir(join(top, '.hg')):
+                        if isdir(_join(join(nd, '.hg'))):
                             continue
                 for f, kind, st in entries:
                     nf = normalize(pconvert(join(nd, f)))
                     if nf in seen:
                         continue
                     seen[nf] = 1
-                    p = join(top, f)
                     # don't trip over symlinks
                     if kind == stat.S_IFDIR:
                         if not ignore(nf):
-                            wadd(p)
+                            wadd(nf)
                             if hasattr(match, 'dir'):
                                 match.dir(nf)
                         if nf in dmap and match(nf):