Comment 6 for bug 90819

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 90819] Re: WorkingTreeFormat4: bzr status README fails on windows

On Sun, 2007-03-11 at 20:10 +0000, John A Meinel wrote:
> This seems to me like it means all callers of _walkdirs will now need to
> check if it is really a directory first, before they call walkdirs.
> Which means they are doing the same work, just now it has to be done by
> every caller, rather than doing it inside one function.
>
> The big reason (in my head) is that walkdirs is the one that touches the
> disk, and most callers don't.
>
> If they already knew whether it was a file or directory (for some
> reason) it would be different. But all they can really know is whether
> they *expect* it to be a file or directory.

Most callers will want details about a path X, and its children. So they
will call:
details = path_info(X)
if details[0] is kind_directory:
    for directory_info in walkdirs(X):
        ....

No special case exception handling required in the caller. And walkdirs
doesn't need to stat or check the path being looked, it can assume the
caller has done that, so nothing is being called or looked at twice.

-Rob

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.