##// 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 st.rename()
398 st.rename()
399 self._dirty = self._dirtypl = False
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 def _dirignore(self, f):
401 def _dirignore(self, f):
416 if f == '.':
402 if f == '.':
417 return False
403 return False
@@ -448,6 +434,16 b' class dirstate(object):'
448 return False
434 return False
449 return match(file_)
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 # TODO: don't walk unknown directories if unknown and ignored are False
447 # TODO: don't walk unknown directories if unknown and ignored are False
452 ignore = self._ignore
448 ignore = self._ignore
453 dirignore = self._dirignore
449 dirignore = self._dirignore
@@ -461,12 +457,12 b' class dirstate(object):'
461 listdir = osutil.listdir
457 listdir = osutil.listdir
462 lstat = os.lstat
458 lstat = os.lstat
463 bisect_left = bisect.bisect_left
459 bisect_left = bisect.bisect_left
464 isdir = os.path.isdir
465 pconvert = util.pconvert
460 pconvert = util.pconvert
466 join = os.path.join
461 join = os.path.join
467 isdir = stat.S_ISDIR
462 getkind = stat.S_IFMT
468 dirkind = stat.S_IFDIR
463 dirkind = stat.S_IFDIR
469 supported = self._supported
464 regkind = stat.S_IFREG
465 lnkkind = stat.S_IFLNK
470 _join = self._join
466 _join = self._join
471 work = []
467 work = []
472 wadd = work.append
468 wadd = work.append
@@ -481,13 +477,15 b' class dirstate(object):'
481
477
482 try:
478 try:
483 st = lstat(_join(nf))
479 st = lstat(_join(nf))
484 if isdir(st.st_mode):
480 kind = getkind(st.st_mode)
481 if kind == dirkind:
485 if not dirignore(nf):
482 if not dirignore(nf):
486 wadd(nf)
483 wadd(nf)
484 elif kind == regkind or kind == lnkkind:
485 results[nf] = st
487 else:
486 else:
488 if supported(ff, st.st_mode, verbose=True):
487 badtype(ff, kind)
489 results[nf] = st
488 if nf in dmap:
490 elif nf in dmap:
491 results[nf] = None
489 results[nf] = None
492 except OSError, inst:
490 except OSError, inst:
493 keep = False
491 keep = False
@@ -529,7 +527,7 b' class dirstate(object):'
529 if nf in dmap and match(nf):
527 if nf in dmap and match(nf):
530 results[nf] = None
528 results[nf] = None
531 elif imatch(nf):
529 elif imatch(nf):
532 if supported(nf, st.st_mode):
530 if kind == regkind or kind == lnkkind:
533 results[nf] = st
531 results[nf] = st
534 elif nf in dmap:
532 elif nf in dmap:
535 results[nf] = None
533 results[nf] = None
@@ -540,7 +538,8 b' class dirstate(object):'
540 results[f] = None
538 results[f] = None
541 try:
539 try:
542 st = lstat(_join(f))
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 results[f] = st
543 results[f] = st
545 except OSError, inst:
544 except OSError, inst:
546 if inst.errno not in (errno.ENOENT, errno.ENOTDIR):
545 if inst.errno not in (errno.ENOENT, errno.ENOTDIR):
General Comments 0
You need to be logged in to leave comments. Login now