##// END OF EJS Templates
dirstate.walk: minor cleanups...
Matt Mackall -
r6828:55d65a33 default
parent child Browse files
Show More
@@ -464,7 +464,8 b' class dirstate(object):'
464 isdir = os.path.isdir
464 isdir = os.path.isdir
465 pconvert = util.pconvert
465 pconvert = util.pconvert
466 join = os.path.join
466 join = os.path.join
467 s_isdir = stat.S_ISDIR
467 isdir = stat.S_ISDIR
468 dirkind = stat.S_IFDIR
468 supported = self._supported
469 supported = self._supported
469 _join = self._join
470 _join = self._join
470 work = []
471 work = []
@@ -480,20 +481,7 b' class dirstate(object):'
480
481
481 try:
482 try:
482 st = lstat(_join(nf))
483 st = lstat(_join(nf))
483 except OSError, inst:
484 if isdir(st.st_mode):
484 keep = False
485 for fn in dmap:
486 if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'):
487 keep = True
488 break
489 if not keep:
490 if inst.errno != errno.ENOENT:
491 fwarn(ff, inst.strerror)
492 elif badfn(ff, inst.strerror) and imatch(nf):
493 yield nf, None
494 continue
495
496 if s_isdir(st.st_mode):
497 if not dirignore(nf):
485 if not dirignore(nf):
498 wadd(nf)
486 wadd(nf)
499 else:
487 else:
@@ -502,6 +490,18 b' class dirstate(object):'
502 yield nf, st
490 yield nf, st
503 elif nf in dmap:
491 elif nf in dmap:
504 yield nf, None
492 yield nf, None
493 except OSError, inst:
494 keep = False
495 prefix = nf + "/"
496 for fn in dmap:
497 if nf == fn or fn.startswith(prefix):
498 keep = True
499 break
500 if not keep:
501 if inst.errno != errno.ENOENT:
502 fwarn(ff, inst.strerror)
503 elif badfn(ff, inst.strerror) and imatch(nf):
504 yield nf, None
505
505
506 # step 2: visit subdirectories
506 # step 2: visit subdirectories
507 while work:
507 while work:
@@ -509,7 +509,6 b' class dirstate(object):'
509 if hasattr(match, 'dir'):
509 if hasattr(match, 'dir'):
510 match.dir(nd)
510 match.dir(nd)
511 entries = listdir(_join(nd), stat=True)
511 entries = listdir(_join(nd), stat=True)
512 # nd is the top of the repository dir tree
513 if nd == '.':
512 if nd == '.':
514 nd = ''
513 nd = ''
515 else:
514 else:
@@ -518,15 +517,13 b' class dirstate(object):'
518 # is good on big directory.
517 # is good on big directory.
519 hg = bisect_left(entries, ('.hg'))
518 hg = bisect_left(entries, ('.hg'))
520 if hg < len(entries) and entries[hg][0] == '.hg' \
519 if hg < len(entries) and entries[hg][0] == '.hg' \
521 and entries[hg][1] == stat.S_IFDIR:
520 and entries[hg][1] == dirkind:
522 continue
521 continue
523 for f, kind, st in entries:
522 for f, kind, st in entries:
524 nf = normalize(pconvert(join(nd, f)))
523 nf = normalize(nd and (nd + "/" + f) or f)
525 if nf in seen:
524 if nf not in seen:
526 continue
527 seen[nf] = 1
525 seen[nf] = 1
528 # don't trip over symlinks
526 if kind == dirkind:
529 if kind == stat.S_IFDIR:
530 if not ignore(nf):
527 if not ignore(nf):
531 wadd(nf)
528 wadd(nf)
532 if nf in dmap and match(nf):
529 if nf in dmap and match(nf):
@@ -539,9 +536,7 b' class dirstate(object):'
539
536
540 # step 3: report unseen items in the dmap hash
537 # step 3: report unseen items in the dmap hash
541 for f in util.sort(dmap):
538 for f in util.sort(dmap):
542 if f in seen or not match(f):
539 if f not in seen and match(f):
543 continue
544 seen[f] = 1
545 try:
540 try:
546 st = lstat(_join(f))
541 st = lstat(_join(f))
547 if supported(f, st.st_mode):
542 if supported(f, st.st_mode):
General Comments 0
You need to be logged in to leave comments. Login now