Technical question about dirstate.statwalk

Paul Moore p.f.moore at gmail.com
Tue May 20 03:15:30 CDT 2008


I'm trying to puzzle out dirstate.statwalk (from crew). Specifically,
in the loop

        for ff in files:
            nf = normpath(ff)
            f = _join(ff)
            [...]
            else:
                if nf in known:
                    continue
                known[nf] = 1
                if match(nf):
                    if supported(ff, st.st_mode, verbose=True):
                        yield 'f', nf, st
                    elif ff in dc:
                        yield 'm', nf, st

Now, files is essentially match.files() which is basically what the
user entered (I believe - correct me if this is wrong). So ff is a
user-supplied value, and nf is the normalised version (redundant
separators and things like /./ or /foo/../ removed). OK, but at the
end we check if ff, not nf, is in dc, where dc is is all or part of
self._map - ie, the internal representation of what is tracked in the
working directory (how accurate is this? is there a better description
of dirstate._map?)

So, if ff (the user-supplied name) is in dc, we yield 'm' plus the
normalised version (which is *not* what we found in dc). Is that
really correct? Surely 'm' should always flag something that was
actually in dc?

I suspect that this is actually a rare corner case, as it only occurs
if we found something in the filesystem, but it isn't a supported
filetype and yet it *is* in the dirstate (presumably it's being
tracked as a supported filetype, but the filesystem has been changed).
So maybe it's not worth worrying about. But I'd like to know if it's a
bug or a misunderstanding on my part - because if I'm
misunderstanding, I probably shouldn't be working on this code!!! :-)

Thanks,
Paul.


More information about the Mercurial-devel mailing list