##// END OF EJS Templates
dirstate.walk: track normalized directory names
Matt Mackall -
r6823:12081ea6 default
parent child Browse files
Show More
@@ -456,11 +456,6 b' class dirstate(object):'
456 ignore = util.never
456 ignore = util.never
457 dirignore = util.never
457 dirignore = util.never
458
458
459 # self._root may end with a path separator when self._root == '/'
460 common_prefix_len = len(self._root)
461 if not util.endswithsep(self._root):
462 common_prefix_len += 1
463
464 normpath = util.normpath
459 normpath = util.normpath
465 normalize = self.normalize
460 normalize = self.normalize
466 listdir = osutil.listdir
461 listdir = osutil.listdir
@@ -482,12 +477,11 b' class dirstate(object):'
482 # step one, find all files that match our criteria
477 # step one, find all files that match our criteria
483 for ff in util.sort(files):
478 for ff in util.sort(files):
484 nf = normalize(normpath(ff))
479 nf = normalize(normpath(ff))
485 f = _join(nf)
486 if nf in seen:
480 if nf in seen:
487 continue
481 continue
488
482
489 try:
483 try:
490 st = lstat(f)
484 st = lstat(_join(nf))
491 except OSError, inst:
485 except OSError, inst:
492 keep = False
486 keep = False
493 for fn in dmap:
487 for fn in dmap:
@@ -513,13 +507,12 b' class dirstate(object):'
513 continue
507 continue
514
508
515 if hasattr(match, 'dir'):
509 if hasattr(match, 'dir'):
516 match.dir(normpath(f[common_prefix_len:]))
510 match.dir(nf)
517 wadd(f)
511 wadd(nf)
518 while work:
512 while work:
519 top = work.pop()
513 nd = work.pop()
520 entries = listdir(top, stat=True)
514 entries = listdir(_join(nd), stat=True)
521 # nd is the top of the repository dir tree
515 # nd is the top of the repository dir tree
522 nd = normpath(top[common_prefix_len:])
523 if nd == '.':
516 if nd == '.':
524 nd = ''
517 nd = ''
525 else:
518 else:
@@ -529,18 +522,17 b' class dirstate(object):'
529 names = [e[0] for e in entries]
522 names = [e[0] for e in entries]
530 hg = bisect_left(names, '.hg')
523 hg = bisect_left(names, '.hg')
531 if hg < len(names) and names[hg] == '.hg':
524 if hg < len(names) and names[hg] == '.hg':
532 if isdir(join(top, '.hg')):
525 if isdir(_join(join(nd, '.hg'))):
533 continue
526 continue
534 for f, kind, st in entries:
527 for f, kind, st in entries:
535 nf = normalize(pconvert(join(nd, f)))
528 nf = normalize(pconvert(join(nd, f)))
536 if nf in seen:
529 if nf in seen:
537 continue
530 continue
538 seen[nf] = 1
531 seen[nf] = 1
539 p = join(top, f)
540 # don't trip over symlinks
532 # don't trip over symlinks
541 if kind == stat.S_IFDIR:
533 if kind == stat.S_IFDIR:
542 if not ignore(nf):
534 if not ignore(nf):
543 wadd(p)
535 wadd(nf)
544 if hasattr(match, 'dir'):
536 if hasattr(match, 'dir'):
545 match.dir(nf)
537 match.dir(nf)
546 if nf in dmap and match(nf):
538 if nf in dmap and match(nf):
General Comments 0
You need to be logged in to leave comments. Login now