##// 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 464 isdir = os.path.isdir
465 465 pconvert = util.pconvert
466 466 join = os.path.join
467 s_isdir = stat.S_ISDIR
467 isdir = stat.S_ISDIR
468 dirkind = stat.S_IFDIR
468 469 supported = self._supported
469 470 _join = self._join
470 471 work = []
@@ -480,10 +481,20 b' class dirstate(object):'
480 481
481 482 try:
482 483 st = lstat(_join(nf))
484 if isdir(st.st_mode):
485 if not dirignore(nf):
486 wadd(nf)
487 else:
488 seen[nf] = 1
489 if supported(ff, st.st_mode, verbose=True):
490 yield nf, st
491 elif nf in dmap:
492 yield nf, None
483 493 except OSError, inst:
484 494 keep = False
495 prefix = nf + "/"
485 496 for fn in dmap:
486 if nf == fn or (fn.startswith(nf) and fn[len(nf)] == '/'):
497 if nf == fn or fn.startswith(prefix):
487 498 keep = True
488 499 break
489 500 if not keep:
@@ -491,17 +502,6 b' class dirstate(object):'
491 502 fwarn(ff, inst.strerror)
492 503 elif badfn(ff, inst.strerror) and imatch(nf):
493 504 yield nf, None
494 continue
495
496 if s_isdir(st.st_mode):
497 if not dirignore(nf):
498 wadd(nf)
499 else:
500 seen[nf] = 1
501 if supported(ff, st.st_mode, verbose=True):
502 yield nf, st
503 elif nf in dmap:
504 yield nf, None
505 505
506 506 # step 2: visit subdirectories
507 507 while work:
@@ -509,7 +509,6 b' class dirstate(object):'
509 509 if hasattr(match, 'dir'):
510 510 match.dir(nd)
511 511 entries = listdir(_join(nd), stat=True)
512 # nd is the top of the repository dir tree
513 512 if nd == '.':
514 513 nd = ''
515 514 else:
@@ -518,39 +517,35 b' class dirstate(object):'
518 517 # is good on big directory.
519 518 hg = bisect_left(entries, ('.hg'))
520 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 521 continue
523 522 for f, kind, st in entries:
524 nf = normalize(pconvert(join(nd, f)))
525 if nf in seen:
526 continue
527 seen[nf] = 1
528 # don't trip over symlinks
529 if kind == stat.S_IFDIR:
530 if not ignore(nf):
531 wadd(nf)
532 if nf in dmap and match(nf):
533 yield nf, None
534 elif imatch(nf):
535 if supported(nf, st.st_mode):
536 yield nf, st
537 elif nf in dmap:
538 yield nf, None
523 nf = normalize(nd and (nd + "/" + f) or f)
524 if nf not in seen:
525 seen[nf] = 1
526 if kind == dirkind:
527 if not ignore(nf):
528 wadd(nf)
529 if nf in dmap and match(nf):
530 yield nf, None
531 elif imatch(nf):
532 if supported(nf, st.st_mode):
533 yield nf, st
534 elif nf in dmap:
535 yield nf, None
539 536
540 537 # step 3: report unseen items in the dmap hash
541 538 for f in util.sort(dmap):
542 if f in seen or not match(f):
543 continue
544 seen[f] = 1
545 try:
546 st = lstat(_join(f))
547 if supported(f, st.st_mode):
548 yield f, st
549 continue
550 except OSError, inst:
551 if inst.errno not in (errno.ENOENT, errno.ENOTDIR):
552 raise
553 yield f, None
539 if f not in seen and match(f):
540 try:
541 st = lstat(_join(f))
542 if supported(f, st.st_mode):
543 yield f, st
544 continue
545 except OSError, inst:
546 if inst.errno not in (errno.ENOENT, errno.ENOTDIR):
547 raise
548 yield f, None
554 549
555 550 def status(self, match, ignored, clean, unknown):
556 551 listignored, listclean, listunknown = ignored, clean, unknown
General Comments 0
You need to be logged in to leave comments. Login now