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