Mercurial > public > mercurial-scm > hg-stable
diff mercurial/posix.py @ 18017:74912fe3d718
dirstate: move file type filtering to its source
This prepares us to move to a much faster statfiles implementation on Unix.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 30 Nov 2012 15:55:07 -0800 |
parents | 9ee25d7b1aed |
children | ae54cff742e2 |
line wrap: on
line diff
--- a/mercurial/posix.py Mon Oct 08 19:34:04 2012 +0200 +++ b/mercurial/posix.py Fri Nov 30 15:55:07 2012 -0800 @@ -352,12 +352,18 @@ def setsignalhandler(): pass +_wantedkinds = set([stat.S_IFREG, stat.S_IFLNK]) + def statfiles(files): - 'Stat each file in files and yield stat or None if file does not exist.' + '''Stat each file in files. Yield each stat, or None if a file does not + exist or has a type we don't care about.''' lstat = os.lstat + getkind = stat.S_IFMT for nf in files: try: st = lstat(nf) + if getkind(st.st_mode) not in _wantedkinds: + st = None except OSError, err: if err.errno not in (errno.ENOENT, errno.ENOTDIR): raise