performance: do not stat() things when not required
Ignore unknown files if we don't need them (eg in hg diff).
It slows things down a little bit for big trees (kernel repo), since _join()
is called for each file instead of for each directory.
fix issue567
abort: Failed to parse .../t/.hg/hgrcFile contains no section headers.file: .../t/.hg/hgrc, line: 1'invalid\n'