##// END OF EJS Templates
dirstate.walk: fold in _supported...
Matt Mackall -
r6830:2cf4cda6 default
parent child Browse files
Show More
@@ -398,20 +398,6 b' class dirstate(object):'
398 398 st.rename()
399 399 self._dirty = self._dirtypl = False
400 400
401 def _supported(self, f, mode, verbose=False):
402 if stat.S_ISREG(mode) or stat.S_ISLNK(mode):
403 return True
404 if verbose:
405 kind = 'unknown'
406 if stat.S_ISCHR(mode): kind = _('character device')
407 elif stat.S_ISBLK(mode): kind = _('block device')
408 elif stat.S_ISFIFO(mode): kind = _('fifo')
409 elif stat.S_ISSOCK(mode): kind = _('socket')
410 elif stat.S_ISDIR(mode): kind = _('directory')
411 self._ui.warn(_('%s: unsupported file type (type is %s)\n')
412 % (self.pathto(f), kind))
413 return False
414
415 401 def _dirignore(self, f):
416 402 if f == '.':
417 403 return False
@@ -448,6 +434,16 b' class dirstate(object):'
448 434 return False
449 435 return match(file_)
450 436
437 def badtype(f, mode):
438 kind = 'unknown'
439 if stat.S_ISCHR(mode): kind = _('character device')
440 elif stat.S_ISBLK(mode): kind = _('block device')
441 elif stat.S_ISFIFO(mode): kind = _('fifo')
442 elif stat.S_ISSOCK(mode): kind = _('socket')
443 elif stat.S_ISDIR(mode): kind = _('directory')
444 self._ui.warn(_('%s: unsupported file type (type is %s)\n')
445 % (self.pathto(f), kind))
446
451 447 # TODO: don't walk unknown directories if unknown and ignored are False
452 448 ignore = self._ignore
453 449 dirignore = self._dirignore
@@ -461,12 +457,12 b' class dirstate(object):'
461 457 listdir = osutil.listdir
462 458 lstat = os.lstat
463 459 bisect_left = bisect.bisect_left
464 isdir = os.path.isdir
465 460 pconvert = util.pconvert
466 461 join = os.path.join
467 isdir = stat.S_ISDIR
462 getkind = stat.S_IFMT
468 463 dirkind = stat.S_IFDIR
469 supported = self._supported
464 regkind = stat.S_IFREG
465 lnkkind = stat.S_IFLNK
470 466 _join = self._join
471 467 work = []
472 468 wadd = work.append
@@ -481,13 +477,15 b' class dirstate(object):'
481 477
482 478 try:
483 479 st = lstat(_join(nf))
484 if isdir(st.st_mode):
480 kind = getkind(st.st_mode)
481 if kind == dirkind:
485 482 if not dirignore(nf):
486 483 wadd(nf)
484 elif kind == regkind or kind == lnkkind:
485 results[nf] = st
487 486 else:
488 if supported(ff, st.st_mode, verbose=True):
489 results[nf] = st
490 elif nf in dmap:
487 badtype(ff, kind)
488 if nf in dmap:
491 489 results[nf] = None
492 490 except OSError, inst:
493 491 keep = False
@@ -529,7 +527,7 b' class dirstate(object):'
529 527 if nf in dmap and match(nf):
530 528 results[nf] = None
531 529 elif imatch(nf):
532 if supported(nf, st.st_mode):
530 if kind == regkind or kind == lnkkind:
533 531 results[nf] = st
534 532 elif nf in dmap:
535 533 results[nf] = None
@@ -540,7 +538,8 b' class dirstate(object):'
540 538 results[f] = None
541 539 try:
542 540 st = lstat(_join(f))
543 if supported(f, st.st_mode):
541 kind = getkind(st.st_mode)
542 if kind == regkind or kind == lnkkind:
544 543 results[f] = st
545 544 except OSError, inst:
546 545 if inst.errno not in (errno.ENOENT, errno.ENOTDIR):
General Comments 0
You need to be logged in to leave comments. Login now