##// END OF EJS Templates
dirstate.walk: pull directory scanning into top-level loop
Matt Mackall -
r6826:eca20fee default
parent child Browse files
Show More
@@ -474,7 +474,7 b' class dirstate(object):'
474 474
475 475 seen = {'.hg': 1}
476 476
477 # step one, find all files that match our criteria
477 # step 1: find all explicit files
478 478 for ff in util.sort(files):
479 479 nf = normalize(normpath(ff))
480 480 if nf in seen:
@@ -495,55 +495,53 b' class dirstate(object):'
495 495 yield nf, None
496 496 continue
497 497
498 if not s_isdir(st.st_mode):
498 if s_isdir(st.st_mode):
499 if not dirignore(nf):
500 wadd(nf)
501 else:
499 502 seen[nf] = 1
500 503 if supported(ff, st.st_mode, verbose=True):
501 504 yield nf, st
502 505 elif nf in dmap:
503 506 yield nf, None
504 continue
505
506 if dirignore(nf):
507 continue
508 507
509 wadd(nf)
510 while work:
511 nd = work.pop()
512 if hasattr(match, 'dir'):
513 match.dir(nd)
514 entries = listdir(_join(nd), stat=True)
515 # nd is the top of the repository dir tree
516 if nd == '.':
517 nd = ''
518 else:
519 # do not recurse into a repo contained in this
520 # one. use bisect to find .hg directory so speed
521 # is good on big directory.
522 hg = bisect_left(entries, ('.hg'))
523 if hg < len(entries) and entries[hg][0] == '.hg' \
524 and entries[hg][1] == stat.S_IFDIR:
525 continue
526 for f, kind, st in entries:
527 nf = normalize(pconvert(join(nd, f)))
528 if nf in seen:
508 # step 2: visit subdirectories
509 while work:
510 nd = work.pop()
511 if hasattr(match, 'dir'):
512 match.dir(nd)
513 entries = listdir(_join(nd), stat=True)
514 # nd is the top of the repository dir tree
515 if nd == '.':
516 nd = ''
517 else:
518 # do not recurse into a repo contained in this
519 # one. use bisect to find .hg directory so speed
520 # is good on big directory.
521 hg = bisect_left(entries, ('.hg'))
522 if hg < len(entries) and entries[hg][0] == '.hg' \
523 and entries[hg][1] == stat.S_IFDIR:
529 524 continue
530 seen[nf] = 1
531 # don't trip over symlinks
532 if kind == stat.S_IFDIR:
533 if not ignore(nf):
534 wadd(nf)
535 if nf in dmap and match(nf):
536 add((nf, None))
537 elif imatch(nf):
538 if supported(nf, st.st_mode):
539 add((nf, st))
540 elif nf in dmap:
541 add((nf, None))
542 for e in util.sort(found):
543 yield e
525 for f, kind, st in entries:
526 nf = normalize(pconvert(join(nd, f)))
527 if nf in seen:
528 continue
529 seen[nf] = 1
530 # don't trip over symlinks
531 if kind == stat.S_IFDIR:
532 if not ignore(nf):
533 wadd(nf)
534 if nf in dmap and match(nf):
535 add((nf, None))
536 elif imatch(nf):
537 if supported(nf, st.st_mode):
538 add((nf, st))
539 elif nf in dmap:
540 add((nf, None))
541 for e in util.sort(found):
542 yield e
544 543
545 # step two run through anything left in the dmap hash and yield
546 # if we haven't already seen it
544 # step 3: report unseen items in the dmap hash
547 545 for f in util.sort(dmap):
548 546 if f in seen or not match(f):
549 547 continue
General Comments 0
You need to be logged in to leave comments. Login now